Skip to content

Commit d8adb83

Browse files
fix(iOS): preserve image orientation (#521)
# Summary Fixes: #506 Fixes: #515 This PR adds preserving EXIF orientation for static images. ## Test Plan Run reproduction steps from issues #506 and #515 The issues should not occur. ## Screenshots / Videos Before: https://github.com/user-attachments/assets/6232666e-e3a9-4a65-bbe6-1ee9cbc51d63 After: https://github.com/user-attachments/assets/75b6176d-46c8-42af-aceb-69035dd47be1 ## Compatibility | OS | Implemented | | ------- | :---------: | | iOS | ✅ | | Android | ❌ | ## Checklist - [ ] E2E tests are passing - [ ] Required E2E tests have been added (if applicable)
1 parent 1b064b8 commit d8adb83

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

ios/extensions/ImageExtension.mm

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,20 @@ static void releaseImages(const std::vector<CGImageRef> &images) {
157157
}
158158

159159
+ (UIImage *)animatedImageWithData:(NSData *)data {
160-
return animatedImageWithReleasingSource(
161-
CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL));
160+
CGImageSourceRef source =
161+
CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
162+
if (!source) {
163+
return nil;
164+
}
165+
166+
// Preserve EXIF orientation for static images (e.g. JPEG/HEIC camera photos)
167+
// by using UIKit decoding path directly.
168+
if (CGImageSourceGetCount(source) <= 1) {
169+
CFRelease(source);
170+
return [UIImage imageWithData:data];
171+
}
172+
173+
return animatedImageWithReleasingSource(source);
162174
}
163175

164176
@end

0 commit comments

Comments
 (0)