Skip to content

Ghostscript (gstoraster): Introduce cupsHalftoneType dithering algorithms #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ValdikSS
Copy link
Contributor

@ValdikSS ValdikSS commented May 26, 2025

Add new dithering (halftone) algorithms in addition to the default Ghostscript one.
Controlled either with halftone-type job option or cupsHalftoneType PPD option.

  • Stochastic algotirhm is implemented in stocht.ps Ghostscript library, just include it if cupsHalftoneType is set to yes/true/on/stochastic.
  • Foo2zjs algorithm is a PostScript code taken from foo2zjs-pstops file (don't know the name of the algorithm)
  • Threshold algorithm

Default algorithm

dither-default

Stochastic algorithm

dither-stoh

Foo2zjs algorithm

dither-foo2zjs

@ValdikSS
Copy link
Contributor Author

ValdikSS commented May 26, 2025

Is it fine to introduce new prefixed PPD option? Some proprietary filters already use Halftone and HalftoneType, so I decided to go with cupsHalftoneType, even if it only applies to Ghostscript-based filter.

cups-filters 1.x: OpenPrinting/cups-filters#642

Copy link
Member

@zdohnal zdohnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks ok on syntax side of things, there are some space/tab issues against applied code style.

Regarding functionality I can't say, since I don't fully understand the best practices and it would be great if it was reviewed by an additional person.

@zdohnal
Copy link
Member

zdohnal commented May 28, 2025

Either way, thank you for the PR, @ValdikSS !

Ad new prefixed option - I would say it is fine, but probably @michaelrsweet should know more.

@ValdikSS ValdikSS force-pushed the ghostscript-dither-repo branch from c17cb8f to 5a71e53 Compare May 29, 2025 17:27
@ValdikSS ValdikSS requested a review from zdohnal May 29, 2025 17:41
Copy link
Member

@zdohnal zdohnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one line scopes should not be enveloped by brackets, otherwise it looks great!

ValdikSS added 2 commits May 30, 2025 12:39
…thms

Add new dithering (halftone) algorithms in addition to the default Ghostscript
one.
Controlled either with `halftone-type` job option or `cupsHalftoneType` PPD
option.

- Stochastic algotirhm is implemented in `stocht.ps` Ghostscript library,
  just include it if cupsHalftoneType is set to yes/true/on/stochastic.
- Foo2zjs algorithm is a PostScript code taken from foo2zjs-pstops file
  (don't know the name of the algorithm)
Similar to pdftoraster implementation.
@ValdikSS ValdikSS force-pushed the ghostscript-dither-repo branch from 5a71e53 to 71742d2 Compare May 30, 2025 09:41
@ValdikSS ValdikSS requested a review from zdohnal May 30, 2025 09:41
Copy link
Member

@zdohnal zdohnal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@michaelrsweet / @tillkamppeter can you review this from functioanity POV (meaning whether halftone implementation is correct)? I have check foo2zjs code and the Postscript code here is matching this PR, bi-level looks feasible with my little knowledge of Postscript, stocht.ps from ghostscript is accessible on machines which includes the script, so LGTM.

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