Skip to content

Fix Image.getSize returning downsampled dimensions on Android#56736

Open
zoontek wants to merge 1 commit intofacebook:mainfrom
zoontek:fix/image-get-size
Open

Fix Image.getSize returning downsampled dimensions on Android#56736
zoontek wants to merge 1 commit intofacebook:mainfrom
zoontek:fix/image-get-size

Conversation

@zoontek
Copy link
Copy Markdown
Contributor

@zoontek zoontek commented May 8, 2026

Summary:

Image.getSize and getSizeWithHeaders call Fresco's fetchDecodedImage, which returns a CloseableImage whose 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 fetchEncodedImage and 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 in RCTImageLoader.

Fixes #33498
Closes facebook/fresco#2236

Changelog:

[ANDROID] [FIXED] - Image.getSize and Image.getSizeWithHeaders now return the true source dimensions instead of Fresco's downsampled values

Test Plan:

In the RNTester app, add:

useEffect(() => {
  Image.getSize(
    'https://images.pexels.com/photos/842711/pexels-photo-842711.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2',
    (width, height) => {
      console.log({width, height});
    },
  );
}, []);

Before

before

After

after

@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 8, 2026
@facebook-github-tools facebook-github-tools Bot added p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels May 8, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 9, 2026

@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D104533593.

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. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

1 participant