Skip to content

fix(graphicsmagick): apply EXIF auto-orient so portrait images don't convert sideways (#590) - #637

Open
thejdubb02 wants to merge 1 commit into
C4illin:mainfrom
thejdubb02:fix/graphicsmagick-auto-orient-590
Open

fix(graphicsmagick): apply EXIF auto-orient so portrait images don't convert sideways (#590)#637
thejdubb02 wants to merge 1 commit into
C4illin:mainfrom
thejdubb02:fix/graphicsmagick-auto-orient-590

Conversation

@thejdubb02

@thejdubb02 thejdubb02 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #590.

A phone portrait photo is stored as landscape pixels plus an EXIF Orientation tag (for example Orientation 6, rotate 90). Converting it with the GraphicsMagick converter produced a landscape result, because gm convert was called without -auto-orient and the target format (PDF here) drops the orientation tag.

#577 fixed this for the ImageMagick converter by adding -auto-orient. This does the same for the GraphicsMagick converter, which is one of the paths the reporter mentions ("ImageMagick or others").

Reproduced with the exact command the converter runs, on a 600x400 JPEG tagged EXIF Orientation 6:

  • gm convert in.jpg out.pdf produced a 600x400 (landscape) PDF page
  • gm convert in.jpg -auto-orient out.pdf produced a 400x600 (portrait) PDF page

A genuinely portrait-pixel image (400x600, no EXIF) already converted to a portrait PDF, so this is specifically EXIF orientation, not page geometry. -auto-orient is a no-op on images with no orientation tag.

Test: mirrors the imagemagick test added in #577, asserting the gm convert args are ["convert", filePath, "-auto-orient", targetPath]. It fails without the change.

One note: like #577, this applies -auto-orient to every GraphicsMagick conversion. If you would rather scope it (some formats and targets can carry the orientation tag themselves, so they may not need it), I am happy to adjust.


Summary by cubic

Fixes #590 by adding -auto-orient to the GraphicsMagick converter. Phone portrait photos (landscape pixels plus an EXIF orientation tag) previously converted to landscape when the target format dropped the tag; now they keep their orientation.

Written for commit 567c585. Summary will update on new commits.

Review in cubic

…convert sideways

A phone portrait photo is stored as landscape pixels plus an EXIF Orientation
tag (e.g. Orientation 6, rotate 90). The GraphicsMagick converter called
`gm convert <in> <out>` without -auto-orient, so converting to a format that
drops the tag (PDF) produced a landscape result. C4illin#577 added -auto-orient to the
ImageMagick converter for the same reason; this does the same for GraphicsMagick.

-auto-orient is a no-op on images with no orientation tag.

Fixes C4illin#590.
@github-actions github-actions Bot added the Fix label Sep 8, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JPEG Portrait to PDF is always Landscape

1 participant