Commit 978d5a2
Fix expo-image-manipulator cropped image orientation (#55379)
Summary:
#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.
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[IOS] [FIXED] - Fix expo-image-manipulator cropped image orientation
bypass-github-export-checks
Pull Request resolved: #55379
Test Plan:
### 0.82.1
https://github.com/mlazari/RNImageRepro/tree/rn-0.82.1
https://github.com/user-attachments/assets/297f6419-980b-49b5-873c-46c43bcc0fd6
### 0.83.1
https://github.com/mlazari/RNImageRepro/tree/0.83.1
https://github.com/user-attachments/assets/286144e7-2196-49cb-b151-26f1a6ff274d
### 0.83.1 + patch with the changes in this PR
https://github.com/mlazari/RNImageRepro/tree/0.83.1-with-patch
https://github.com/user-attachments/assets/72ed6e74-a2cd-4b0d-b529-d91d0fdb3d52
Reviewed By: javache
Differential Revision: D92148021
Pulled By: cipolleschi
fbshipit-source-id: 0e485379b533fb415cb9d7946276a3de416578921 parent 485bbda commit 978d5a2
1 file changed
Lines changed: 37 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
58 | 82 | | |
59 | 83 | | |
60 | 84 | | |
| |||
269 | 293 | | |
270 | 294 | | |
271 | 295 | | |
| 296 | + | |
272 | 297 | | |
273 | 298 | | |
274 | 299 | | |
| |||
293 | 318 | | |
294 | 319 | | |
295 | 320 | | |
| 321 | + | |
296 | 322 | | |
297 | 323 | | |
298 | 324 | | |
299 | 325 | | |
300 | 326 | | |
301 | 327 | | |
| 328 | + | |
| 329 | + | |
302 | 330 | | |
303 | 331 | | |
304 | 332 | | |
| |||
313 | 341 | | |
314 | 342 | | |
315 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
316 | 352 | | |
317 | 353 | | |
318 | 354 | | |
| |||
321 | 357 | | |
322 | 358 | | |
323 | 359 | | |
324 | | - | |
| 360 | + | |
325 | 361 | | |
326 | 362 | | |
327 | 363 | | |
| |||
0 commit comments