Skip to content

fix: bake EXIF orientation into pixels for all outputs - #511

Merged
thisismana merged 1 commit into
mainfrom
fix-orientation-bug
Jul 30, 2026
Merged

fix: bake EXIF orientation into pixels for all outputs#511
thisismana merged 1 commit into
mainfrom
fix-orientation-bug

Conversation

@thisismana

@thisismana thisismana commented Jul 30, 2026

Copy link
Copy Markdown
Member

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

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>
@thisismana
thisismana merged commit 50b2a6b into main Jul 30, 2026
7 checks passed
@thisismana
thisismana deleted the fix-orientation-bug branch July 30, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants