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.

Image.getSize not returning correct image dimension from url

See original GitHub issue

Description

image

  • Image is taken from ‘react-native’;

The above getSize method from react-native returns the minimum of dp of the screen and size of image(height/width) For example, dp = 1920 image width = 800 The returned width is 800

If image width. = 3000 The returned width is 1920.

Shouldn’t the getSize return the size of the image?

Version

0.66.4

Output of npx react-native info

System: OS: macOS 12.3 CPU: (8) x64 Apple M1 Pro Memory: 25.67 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.17.5 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 6.14.14 - /usr/local/bin/npm Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: API Levels: 29, 30, 31 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0 System Images: android-25 | Google APIs ARM EABI v7a, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-Sv2 | Google APIs ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8139111 Xcode: 13.3/13E113 - /usr/bin/xcodebuild Languages: Java: 11.0.11 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.4 => 0.66.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

  1. Use a 1920x1080 resolution screen.
  2. Grab a 4k or 8k image.
  3. Use the getSize method of Image to get the size of the image.

Snack, code example, screenshot, or link to a repository

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
divyaswormakaicommented, Apr 1, 2022

Hi @Marcoo09,

Thank you for the reply. The package that you have mentioned does work but if you look into the library, they convert the image to a bitmap and then get the real image dimension from it. It works okay for small images but for large images, it takes too much processing time directly hampering the app flow. I have addressed this in the git repo as well. https://github.com/eXist-FraGGer/react-native-image-size/issues/13

Also thank you for reopening the issue on the fresco.

0reactions
anurag-adhikaricommented, Sep 30, 2022

Looking forward to knowing more…

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Retrieve Actual Image Sizes - Stack Overflow
Image component now provides a static method to get the size of the image. For example: Image.getSize(myUri, (width, height) => {this.
Read more >
Image - React Native
A React component for displaying different types of images, including network images, static resources, temporary local images, and images ...
Read more >
How can I use Image.getSize for all items in an array ... - Reddit
I'm trying to full width (and proportionately) display an image, so I need to get the height to then determine the aspect ratio, ......
Read more >
add_image_size() | Function - WordPress Developer Resources
Set the image size by cropping the image (not showing part of it):. Copy. add_image_size( 'custom-size', 220, 180, true ); // 220 pixels...
Read more >
Example of getSize on Image in React Native Get Dimensions
Contents in this project Example of getSize on Image in React Native Get Dimensions :- · Image.getSize(imageURL, (Width, Height) => { · setWidth( ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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