Fix expo-image-manipulator cropped image orientation#55379
Closed
mlazari wants to merge 1 commit intofacebook:mainfrom
Closed
Fix expo-image-manipulator cropped image orientation#55379mlazari wants to merge 1 commit intofacebook:mainfrom
mlazari wants to merge 1 commit intofacebook:mainfrom
Conversation
facebook#54184 introduced a change that uses `CGImageSourceCreateImageAtIndex` instead of `CGImageSourceCreateThumbnailAtIndex` to decode full-sized images. However, unlike `CGImageSourceCreateThumbnailAtIndex` which rotates the image according to the orientation in the image's metadata, `CGImageSourceCreateThumbnailAtIndex` doesn't do that. Since the UIImage initializer is always passed `UIImageOrientationUp` for orientation, this results in the returned `UIImage` having wrong orientation. This can be reproduced for example if you take a photo with `react-native-vision-camera` in an orientation different from "up" (e.g. taking a photo on an iPhone SE 2020 in a vertical position results in a photo with "landscape-right" orientation), then use PhotoManipulator.crop() to crop the image, then show the resulted image URI in an Image component - the image is shown in a wrong orientation. This change fixes that by making sure the UIImage is passed the correct image orientation when `CGImageSourceCreateImageAtIndex` is used.
tsapeta
reviewed
Feb 2, 2026
Contributor
tsapeta
left a comment
There was a problem hiding this comment.
I'm sorry for breaking it 🙈 This change looks good to me!
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D92148021. |
|
@cipolleschi merged this pull request in 978d5a2. |
Collaborator
|
This pull request was successfully merged by @mlazari in 978d5a2 When will my fix make it into a release? | How to file a pick request? |
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.
Summary:
#54184 introduced a change that uses
CGImageSourceCreateImageAtIndexinstead ofCGImageSourceCreateThumbnailAtIndexto decode full-sized images. However, unlikeCGImageSourceCreateThumbnailAtIndexwhich rotates the image according to the orientation in the image's metadata,CGImageSourceCreateThumbnailAtIndexdoesn't do that. Since the UIImage initializer is always passedUIImageOrientationUpfor orientation, this results in the returnedUIImagehaving wrong orientation.This can be reproduced for example if you take a photo with
react-native-vision-camerain an orientation different from "up" (e.g. taking a photo on an iPhone SE 2020 in a vertical position results in a photo with "landscape-right" orientation), then use PhotoManipulator.crop() to crop the image, then show the resulted image URI in an Image component - the image is shown in a wrong orientation.This change fixes that by making sure the UIImage is passed the correct image orientation when
CGImageSourceCreateImageAtIndexis used.Changelog:
[IOS] [FIXED] - Fix expo-image-manipulator cropped image orientation
Test Plan:
0.82.1
https://github.com/mlazari/RNImageRepro/tree/rn-0.82.1
0.82.1.mov
0.83.1
https://github.com/mlazari/RNImageRepro/tree/0.83.1
0.83.1.mov
0.83.1 + patch with the changes in this PR
https://github.com/mlazari/RNImageRepro/tree/0.83.1-with-patch
0.83.1-with-patch.mov