fix: bake EXIF orientation into pixels for all outputs - #511
Merged
Conversation
Auto-converted images (esp. WebP) kept the source's EXIF Orientation tag
instead of physically rotating the pixels. WebKit honors that tag, Blink
ignores it, so rotated phone photos rendered sideways in Chrome but upright
in Safari. The old pipeline never auto-oriented and actively re-injected the
stale tag via `.withMetadata({ orientation })`.
Call `.autoOrient()` on the pipeline before any resize/crop so the pixels are
rotated once and the tag is normalized, consistently across WebP/JPEG/AVIF/PNG.
`autoOrient()` wins over `keepMetadata()`, so no stale Orientation is written back.
While here, rebase metadata handling onto the modern sharp API to match
upstream (keepIccProfile/keepMetadata/withExif/withIccProfile), replacing the
`withMetadata()/rotate:null` pattern.
Behavior changes:
- `strip_exif` and `strip_icc` are now independent: `strip_exif` keeps the ICC
profile, `strip_icc` keeps EXIF (previously both dropped all metadata via the
`rotate:null` hack).
- Default outputs no longer carry sharp's injected sRGB ICC profile; sRGB is
the assumed default, so this is visually identical and slightly smaller.
- ratio resize now swaps width/height for 90/270 orientations, since
`metadata()` reports pre-autoOrient dimensions.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bastianpahlke
approved these changes
Jul 30, 2026
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.
Auto-converted images (esp. WebP) kept the source's EXIF Orientation tag
instead of physically rotating the pixels. WebKit honors that tag, Blink
ignores it, so rotated phone photos rendered sideways in Chrome but upright
in Safari. The old pipeline never auto-oriented and actively re-injected the
stale tag via
.withMetadata({ orientation }).Call
.autoOrient()on the pipeline before any resize/crop so the pixels arerotated once and the tag is normalized, consistently across WebP/JPEG/AVIF/PNG.
autoOrient()wins overkeepMetadata(), so no stale Orientation is written back.While here, rebase metadata handling onto the modern sharp API to match
upstream (keepIccProfile/keepMetadata/withExif/withIccProfile), replacing the
withMetadata()/rotate:nullpattern.Behavior changes:
strip_exifandstrip_iccare now independent:strip_exifkeeps the ICCprofile,
strip_icckeeps EXIF (previously both dropped all metadata via therotate:nullhack).the assumed default, so this is visually identical and slightly smaller.
metadata()reports pre-autoOrient dimensions.Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com