Repository navigation
fix(compress): stop Ghostscript from turning pages in pass A - #210
Merged
Merged
Conversation
Pass A of Compress runs Ghostscript pdfwrite with -dPDFSETTINGS and no AutoRotatePages switch, so gs turns pages by the direction of their text. /ebook, the default level in PDFApps, implies /All: it applies one rotation, that of the document's dominant text, to every page. /screen implies /PageByPage: it turns each page to the direction of its own text. Either way the user can get pages in an orientation the source did not have. Pass -dAutoRotatePages=/None right after -dPDFSETTINGS, on every level. Measured with gs 10.05.0 on Windows and gs 10.06.0 on WSL Ubuntu, with identical results on both: - two pages, page 1 with horizontal text and page 2 with text at 90 degrees: without the switch, /ebook turned both pages 90 degrees clockwise, leaving page 1 on its side, and /screen left page 1 alone and turned page 2; - page 1 stored with /Rotate 90: without the switch, /ebook left that page upside down; - with the switch, no page turned on either version or preset. The code comment also lists gs 9.55.0 among the versions it was measured on; that version was not re-checked for this change. tests/test_compress_gs_autorotate.py adds 11 tests: 3 check the pass A argv on each level with a faked gs, 8 run the real gs on four fixtures under /ebook and /screen and are skipped when no gs is found. All 11 pass with the switch and all 11 fail without it. Full suite: 1049 passed, 2 skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pass A of Compress runs Ghostscript pdfwrite with
-dPDFSETTINGSand noAutoRotatePagesswitch, so gs turns pages by the direction of their text:/ebook, the default level in PDFApps, implies/All: it applies one rotation, that of the document's dominant text, to every page./screenimplies/PageByPage: it turns each page to the direction of its own text.This changes the orientation the user sees. The fix passes
-dAutoRotatePages=/Noneright after-dPDFSETTINGS, on every level.Files:
app/utils.py,tests/test_compress_gs_autorotate.py(new, 11 tests).Measurements
gs 10.05.0 on Windows and gs 10.06.0 on WSL Ubuntu gave identical results.
/ebook/screen/Rotate 90/ebookThe code comment also lists gs 9.55.0 among the versions it was measured on; that version was not re-checked for this change.
Tests
/ebookand/screen, and are skipped when no gs is found.🤖 Generated with Claude Code