question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android][react-native] incorrect image width and height - CloseableImage getWidth/getHeight

See original GitHub issue

Description

On react native, Image.getSize() uses Fresco (here) to return the width and height of a given image.

As explaned in this react-native issue (https://github.com/facebook/react-native/issues/22145), the returned width and height are inconsistent in Android. The ratio between width and height is correct, but the values of width and height are not.

Reproduction

See example in https://github.com/facebook/react-native/issues/22145

Additional Information

react: 16.5.0 => 16.5.0 react-native: 0.57.1 => 0.57.1

  • Fresco version: com.facebook.fresco:fresco-1.10.0
  • Platform version: Android 6.0.1 (One plus One); Android 7.0 (Huawei MediaPad T3 10);

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AInoobcommented, Feb 4, 2020

If you are using Expo, then you can use ImageManipulator.manipulateAsync to flip the image and get the REAL image size. https://docs.expo.io/versions/v36.0.0/sdk/imagemanipulator/

1reaction
bartolkaruzacommented, Dec 29, 2018

@oprisnik I think you can close this issue, as the downsampling seems to be the cause and the downsampled value is more useful for layout concerns. People are ending up on facebook/react-native#22145 because they want to use Image.getSize for image processing after taking an image from a camera. The reason this is even used by people is this bug on the react-native-camera repo which returns the captured image size, but with a delay: https://github.com/react-native-community/react-native-camera/issues/768

In short IMO, won’t fix on React Native and not a bug for Fresco. Thanks for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expo React-Native getSize() method returns wrong height and ...
I have project where I am trying to get remote image dimensions with getSize() method, problem is that this method ...
Read more >
Images - React Native
Images. Static Image Resources​. React Native provides a unified way of managing images and other media assets in your Android and iOS apps....
Read more >
com.facebook.common.logging.FLog Java Exaples
Get image width and height from jpeg header * @param is the input stream of jpeg image * @return dimensions of the image...
Read more >
React Native Get HTTP Remote Image Height Width Size in ...
Image component has inbuilt method known as Image.getSize().Find Online remote server image dimensions in pixels in Image Wallpaper ...
Read more >
Java Examples for com.facebook.drawee.drawable.ScalingUtils
setScaleType(scaleType); if (image != null) { debugOverlay.setDimensions(image.getWidth(), image.getHeight()); debugOverlay.setImageSize(image.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found