Skip to content

Fix image EXIF orientation not being applied on macOS#66

Merged
viktorstrate merged 1 commit intoviktorstrate:mainfrom
beezly:fix/image-exif-orientation
Mar 10, 2026
Merged

Fix image EXIF orientation not being applied on macOS#66
viktorstrate merged 1 commit intoviktorstrate:mainfrom
beezly:fix/image-exif-orientation

Conversation

@beezly
Copy link
Contributor

@beezly beezly commented Mar 9, 2026

Problem

Images taken in portrait mode on a phone appear rotated 90° in the timeline. The raw sensor data is stored in landscape orientation, with an EXIF tag instructing viewers to rotate it 90° for correct display.

Root Cause

Image(importing:contentType:) on macOS does not apply EXIF orientation metadata — it renders the raw pixel data as-is. This is a macOS-specific issue; on iOS, UIImage applies EXIF orientation automatically.

Fix

Route image decoding through CIImage.oriented(_:), which reads the EXIF orientation tag from the image metadata and applies the correct rotation/flip transform. The oriented CIImage is then wrapped in NSCIImageRepNSImageImage(nsImage:) for SwiftUI rendering.

A toOrientedImage(contentType:) helper is added to Data and used in both image loading paths (MessageImageView and MatrixClient.loadImage).

Image(importing:contentType:) on macOS does not apply EXIF orientation
metadata, causing images taken in portrait mode to appear rotated 90
degrees (the raw sensor data is landscape, with an EXIF tag saying to
rotate it).

Fix by routing image decoding through CIImage.oriented(_:) which reads
the EXIF orientation tag and applies the correct rotation transform.
The result is wrapped in NSCIImageRep/NSImage for SwiftUI rendering.
@viktorstrate
Copy link
Owner

Confirmed with sample images, thank you for the fix!

@viktorstrate viktorstrate merged commit 4aea7ad into viktorstrate:main Mar 10, 2026
2 checks passed
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