Skip to content

Add Image.getSize device coverage (#56746)#56746

Open
Abbondanzo wants to merge 3 commits intofacebook:mainfrom
Abbondanzo:export-D104535939
Open

Add Image.getSize device coverage (#56746)#56746
Abbondanzo wants to merge 3 commits intofacebook:mainfrom
Abbondanzo:export-D104535939

Conversation

@Abbondanzo
Copy link
Copy Markdown
Contributor

@Abbondanzo Abbondanzo commented May 9, 2026

Summary:

Add an RNTester PlatformTest case that calls Image.getSize against a small PNG, a large JPEG, and an EXIF-rotated JPEG, then verifies the dimensions reported by native image metadata. Extend the existing Image Maestro flow to open the new test and wait for the pass result, so the same flow can run against Android and iOS RNTester builds.

Changelog:
[Internal][Added] - Add RNTester device coverage for Image.getSize dimensions

Differential Revision: D104535939

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 9, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels May 9, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 9, 2026

@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D104535939.

Summary: This changes Android Image.getSize to return dimensions from encoded image metadata instead of the decoded CloseableImage so callers get the source image dimensions rather than dimensions affected by resize/downsampling. The EXIF-rotated JPEG case exposed a second Android-specific wrinkle: Fresco EncodedImage width/height are populated through BitmapUtil.decodeDimensionsAndColorSpace, which delegates to Android BitmapFactory bounds decoding. For the Landscape_6.jpg sample, BitmapFactory reports the encoded height as 1792 even though the JPEG SOF marker declares 1800. After applying the 90-degree EXIF rotation swap, that decoder-rounded bound becomes a returned width of 1792, while iOS returns the correct visible source dimensions of 1800x1200. Fresco is not intentionally changing the Image.getSize contract here; it is surfacing Android decoder-derived bounds that are useful for decode metadata but too imprecise for this API. To make Image.getSize match iOS and the source file, Android now reads exact JPEG SOF dimensions from the encoded stream when available, falls back to EncodedImage dimensions for other formats, and then applies the existing EXIF rotation swap.

Differential Revision: D104533593
Summary:
Android BitmapFactory bounds decoding can report rounded JPEG dimensions for the EXIF-rotated sample covered by RNTester. Read JPEG SOF dimensions from the encoded stream before applying EXIF rotation so Image.getSize returns the source dimensions consistently with iOS.

Changelog: [Android][Fixed] Fix Image.getSize source dimensions for JPEGs whose Android bounds decoder reports rounded metadata.

Differential Revision: D104600373
Summary:
Pull Request resolved: facebook#56746

Add an RNTester PlatformTest case that calls Image.getSize against a small PNG, a large JPEG, and an EXIF-rotated JPEG, then verifies the dimensions reported by native image metadata. Extend the existing Image Maestro flow to open the new test and wait for the pass result, so the same flow can run against Android and iOS RNTester builds.

Changelog:
[Internal][Added] - Add RNTester device coverage for Image.getSize dimensions

Differential Revision: D104535939
@Abbondanzo Abbondanzo force-pushed the export-D104535939 branch from 3edcde1 to e9594d0 Compare May 11, 2026 02:55
@meta-codesync meta-codesync Bot changed the title Add Image.getSize device coverage Add Image.getSize device coverage (#56746) May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant