Skip to content

Ghostscript (gstoraster): new halftone/dithering algorithms#160

Merged
tillkamppeter merged 3 commits into
OpenPrinting:masterfrom
ValdikSS:master-new-halftone
Jun 23, 2026
Merged

Ghostscript (gstoraster): new halftone/dithering algorithms#160
tillkamppeter merged 3 commits into
OpenPrinting:masterfrom
ValdikSS:master-new-halftone

Conversation

@ValdikSS

@ValdikSS ValdikSS commented Jun 22, 2026

Copy link
Copy Markdown
Member

Add new dithering and halftoning algorithms in addition to the existing stochastic, bi-level and foo2zjs algorithms.
Controlled either with halftone-type job option or cupsHalftoneType PPD option.

  • dithering, forces 8x8 ordered dithering (no halftone) used only for low DPI in Ghostscript by default
  • genordered, a configurable halftone+ordered dithering algorithm
  • spot, a configurable halftone algorithm from PDF specification
* -o halftone-type=dithering, forces 8x8 ordered dithering
* -o halftone-type=genordered[-frequency][-angle][-dotshape]
* -o halftone-type=spot[-frequency][-angle][-dotshape]

genordered is a halftone+ordered dithering algorithm,
  frequency - line-per-inch, number of halftone cells per inch.
              Lower produces larger dots, higher - smaller.
              Values good for 203DPI label printer: 50-60
                              600DPI laser printer: 106-150
  angle - screen orientation, in degrees.
  dotshape - one of:
    0=CIRCLE, 1=REDBOOK, 2=INVERTED, 3=RHOMBOID, 4=LINE_X, 5=LINE_Y,
    6=DIAMOND1, 7=DIAMOND2, 8=ROUNDSPOT

spot is a halftone algorithm from PDF specification,
  frequency, angle - same as for genordered
  dotshape - one of:
    0=SimpleDot 1=InvertedSimpleDot 2=DoubleDot 3=InvertedDoubleDot
    4=CosineDot 5=Double 6=InvertedDouble 7=Line 8=LineX 9=LineY 10=Round
    11=Ellipse 12=EllipseA 13=InvertedEllipseA 14=EllipseB 15=EllipseC
    16=InvertedEllipseC 17=Square 18=Cross 19=Rhomboid 20=Diamond

full readme is in 1.x commit, and in commit messages

dithering is mostly useful for label and other low-DPI printers, other algorithms are for all printers.

Source image

orig

Stock configuration, no halftone-type

00_stock pbm

Stochastic

04_stocht pbm

8x8 Dithering

03_8x8dither pbm

genordered-60-135

01_genordered pbm

spot-60-135

02_PDF_SimpleDot pbm

ValdikSS added 3 commits June 23, 2026 01:53
Controlled either with `halftone-type` job option or `cupsHalftoneType`
PPD option.

halftone-type=dithering
or
cupsHalftoneType=dithering

Square 8×8 ordered dither, contributed to Ghostscript by
Gregg Townsend.
Advanced ordered dithering halftone screen algorithm, controlled either with
`halftone-type` job option or `cupsHalftoneType` PPD option.

halftone-type=genordered[-frequency][-angle][-dotshape]

frequency - line-per-inch, number of halftone cells per inch.
            Lower produces larger dots, higher - smaller.
            Values good for 203DPI label printer: 50-60
                            600DPI laser printer: 106-150
angle - screen orientation, in degrees.
dotshape - one of:
    0=CIRCLE, 1=REDBOOK, 2=INVERTED, 3=RHOMBOID, 4=LINE_X, 5=LINE_Y,
    6=DIAMOND1, 7=DIAMOND2, 8=ROUNDSPOT

Examples
halftone-type=genordered-60-45
halftone-type=genordered-133-135-8

More information could be found in Ghostscript documentation:
https://ghostscript.readthedocs.io/en/gs10.07.1/Language.html#:~:text=%2Egenordered
Advanced ordered dithering halftone screen algorithm, controlled either with
`halftone-type` job option or `cupsHalftoneType` PPD option.

halftone-type=spot[-frequency][-angle][-dotshape]

frequency - line-per-inch, number of halftone cells per inch.
            Lower produces larger dots, higher - smaller.
            Values good for 203DPI label printer: 50-60
                            600DPI laser printer: 106-150
angle - screen orientation, in degrees.
dotshape - one of:
    0=SimpleDot 1=InvertedSimpleDot 2=DoubleDot 3=InvertedDoubleDot 4=CosineDot
    5=Double 6=InvertedDouble 7=Line 8=LineX 9=LineY 10=Round 11=Ellipse
    12=EllipseA 13=InvertedEllipseA 14=EllipseB 15=EllipseC 16=InvertedEllipseC
    17=Square 18=Cross 19=Rhomboid 20=Diamond

Examples
halftone-type=spot-60-45-20
halftone-type=spot-133-135-4

More information could be found in PDF specification, pages 303-307:
https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf
@tillkamppeter tillkamppeter merged commit b2b81f8 into OpenPrinting:master Jun 23, 2026
15 checks passed
@ValdikSS

Copy link
Copy Markdown
Member Author

Quite unfortunate that the MR got squashed, as the commit messages contain useful information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants