Fix Image.getSize returning downsampled dimensions on Android#56736
Open
zoontek wants to merge 1 commit intofacebook:mainfrom
Open
Fix Image.getSize returning downsampled dimensions on Android#56736zoontek wants to merge 1 commit intofacebook:mainfrom
zoontek wants to merge 1 commit intofacebook:mainfrom
Conversation
|
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D104533593. |
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:
Image.getSizeandgetSizeWithHeaderscall Fresco'sfetchDecodedImage, which returns aCloseableImagewhose width / height reflect the bitmap after Fresco's automatic downsampling (typically capped at the screen size).For sources larger than the screen this returned the wrong dimensions. ex: a 4000x3000 image on a 1920x1080 device came back as 1920x1440.
Switch to
fetchEncodedImageand read the dimensions from the parsed image metadata (JPEG / PNG / WebP / HEIF headers), so the values are the true source dimensions. Swap width / height for 90°/270° EXIF rotation to match the iOS behavior inRCTImageLoader.Fixes #33498
Closes facebook/fresco#2236
Changelog:
[ANDROID] [FIXED] -
Image.getSizeandImage.getSizeWithHeadersnow return the true source dimensions instead of Fresco's downsampled valuesTest Plan:
In the RNTester app, add:
Before
After