Skip to content

Preserve camera photo orientation when transcoding - #16554

Open
AksharP5 wants to merge 1 commit into
omacom:quattrofrom
AksharP5:fix-photo-orientation
Open

AksharP5 wants to merge 1 commit into
omacom:quattrofrom
AksharP5:fix-photo-orientation

Conversation

@AksharP5

Copy link
Copy Markdown
Contributor

Camera photos can come out sideways when transcoded for sharing: the JPG path strips EXIF orientation without rotating the stored pixels. Apply -auto-orient before resizing in both JPG and PNG conversion so the exported pixels have the intended orientation.

Using the same 120x80 JPEG with EXIF Orientation=6:

Output Before After
JPG 120x80, orientation removed, arrow points right 80x120, orientation removed, arrow points down
PNG 120x80, RightTop orientation chunk, unrotated pixels 80x120, TopLeft, arrow points down

Ran the full helper with real ImageMagick 7.1.2-33, stubbing only translation, clipboard, and notifications. Inspected the exported images against a separately rotated reference. Ordinary JPG output stays byte-identical; ordinary PNG pixels stay identical, with orientation normalized to TopLeft. bash -n and git diff --check pass. The synthetic fixture and reproduction are in the linked issue.

Based on current quattro at 50e229d08. #16329 touches this area for different format/resolution work; this change only applies orientation.

Fixes #16553

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds -auto-orient before resizing in both JPG and PNG exports.

  • JPG and PNG exports apply camera orientation before resizing.

Reviews (1) · Last reviewed commit: "Preserve camera photo orientation when t..." · Reviewed by Greptile

CommanderTurtle added a commit to CommanderTurtle/PR--omacom--omarchy--bin-omarchy-transcode that referenced this pull request Oct 25, 2026
Includes the JPG/PNG auto-orient fix proposed by AksharP5 in omacom#16554, extended to static WebP/AVIF intermediates. Keep source files and encoder quality settings unchanged; cover rotated, mirrored, normal and untagged inputs in the existing bench.
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at b4479a1, nothing found. The bug is real and this fixes it.

What was run. On a disposable Omarchy worker (ImageMagick 7.1.2-35), I transcoded a 120x80 JPEG tagged EXIF Orientation=6, using a fixture of my own. I compared quattro's bin/omarchy-transcode with this head, both writing low output:

  • quattro: both the jpg and png exports come out 120x80 and sideways. The jpg loses its orientation tag. The png keeps RightTop over unrotated pixels.
  • this head: both come out 80x120 and match a -rotate 90 reference (png exact, jpg within JPEG recompression).
  • An untagged picture gives pixel-identical output on both, for jpg and png.
  • A HEIC made from the same photo comes out upright and identical on both. ImageMagick's HEIC decoder already applies the rotation, so -auto-orient does nothing there and cannot rotate it twice.
  • ./test/cli passes on the worker.

Second opinion. Codex Medium and muse-wonder (pi, thinking high) both reviewed the diff, its callers and the other magick call sites in bin/. Neither found a defect, and both found the two-line change proportionate. They agreed with my reading, and their independence is not guaranteed. One detail came from them: ImageMagick's PNG writer still emits an orNT orientation chunk despite png:exclude-chunk=all. After this change that chunk says TopLeft, which matches the pixels, so nothing shows up wrong.

Related. #16329 later added the same -auto-orient to these lines as part of its larger transcode rework. This PR is the earlier and focused fix for #16553, so it is the one brought forward. Whichever merges second will need a small rebase on these two lines.

Nothing is left for the author. This waits on the maintainer.

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

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transcoding camera photos to JPG loses their EXIF rotation

2 participants