Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Optimise graphics (PNG+PDF) with zopflipng and ghostscript#5529

Closed
Rigo-V wants to merge 2 commits into
apple:masterfrom
Rigo-V:ghostscript
Closed

Optimise graphics (PNG+PDF) with zopflipng and ghostscript#5529
Rigo-V wants to merge 2 commits into
apple:masterfrom
Rigo-V:ghostscript

Conversation

@Rigo-V

@Rigo-V Rigo-V commented Feb 24, 2019

Copy link
Copy Markdown

Shaved 1.8MiB off the pdf files test/*.pdf.

@Rigo-V

Rigo-V commented Feb 24, 2019

Copy link
Copy Markdown
Author

This seems to contain the PNG optimisations from the pull request 5527 as well, so I closed that one.

@Rigo-V Rigo-V changed the title Optimise test PDFs Optimise graphics (PNG+PDF) with zopflipng and ghostscript Feb 24, 2019
@michaelrsweet

Copy link
Copy Markdown
Contributor

Since these files are generated using a separate program, and since Ghostscript-generated PDFs are not always the nicest, I hesitate to accept this pull request. Will investigate incorporating zopflipng (or something like it) into the PNG generation toolchain, but Ghostscript is a non-starter for this.

@michaelrsweet michaelrsweet added this to the Future milestone Feb 25, 2019
@michaelrsweet michaelrsweet self-assigned this Feb 25, 2019
@Rigo-V

Rigo-V commented Feb 25, 2019

Copy link
Copy Markdown
Author

I understand your hesitation regarding the use of ghostscript. It sometimes make ugly pdfs. I used this command:
gs -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.4 -sOutputFile=file.pdf file.pdf.uncompressed
for compressing onepage-a4.pdf, onepage-letter.pdf, document-a4.pdf and document-letter.pdf, and cannot notice any loss of detail in the compressed files.
I cannot remember which exact command I used for the testfile.pdf, but there seems to be no degradation in it either (apart from the non-functioning hyperlinks, but that shouldn't be much of a problem since the file is for testing printing, right?

It'd obviously be fantastic if you incorporated optimisations in your toolchain itself. If that happens I definitely wouldn't mind this PR be rejected. Zopflipng seems like the best but also the slowest. But since the PNGs seem to be changed very rarely, this shouldn't be much of an issue.
I use the following options myself:
--iterations=500 --filters=01234mepb --lossy_transparent

michaelrsweet added a commit that referenced this pull request May 15, 2019
@michaelrsweet michaelrsweet added the enhancement New feature or request label May 15, 2019
@michaelrsweet michaelrsweet modified the milestones: Future, CUPS 2.3.x May 15, 2019
@michaelrsweet

Copy link
Copy Markdown
Contributor

OK, I've done a bunch of testing and am happy with the results. Changes are getting pushed now...

@michaelrsweet

Copy link
Copy Markdown
Contributor

OK, changes are now merged.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants