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.

support for resizeMethod

See original GitHub issue

Hi,

I have a list of rather large images, and I want smooth scroll behavior. If I use react native’s Image with resizeMethod set to resize, I get a performance boost over FastImage but I lose the caching and loading optimizations of FastImage. Is there a reason why FastImage doesn’t support resizeMethod prop?

thanks.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:17
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mraljcommented, Jun 29, 2019

I haven’t tried forked version, but I have applied “dirty fix” in FastImageViewManager.java Just for test I have changed this line .apply(FastImageViewConverter.getOptions(source)) to .apply(FastImageViewConverter.getOptions(source).override(600, 400) )

And on performance was night and day. I was testing feed feature with a lot of images, and it was crashing on the first “page” on Galaxy S6 edge. After changing single line as described above, not only that it wasn’t crashing anymore, but I could scroll like crazy and everything was working 👌

So I really think @adammcarth’s PR should get merged. 🤞

In the mean time, switching from FastImage to regular Image also fixed issue (but performance wise solution described above was better). My image component looks like this now:

 <Image
            style={style.media}
            source={{ uri: backgroundImage }}
            source={{ uri: backgroundImage, cache: "force-cache" }}
            resizeMode={"cover"}
            resizeMethod={"resize"} // <-------  this helped a lot as OP said
            progressiveRenderingEnabled={true} <---- as well as this 
          />

2reactions
adammcarthcommented, Jan 31, 2019

Alright, for anyone else having this issue - I’d suggest making sure you’re running at least version 5.1.0. We were running version 4.0.14, and the upgrade alone seemed to dramatically improve performance from unusable to acceptable. This is (I suspect) largely due to the upgraded major version of Glide.

For those still experiencing problems on Android with large down-sized images, I’ve created a fork of the latest version which introduces a new prop to manually downsize images before they’re loaded into the RAM. The only caveat is that you must know the exact resolution that you want to downsize to.

Usage Example:

<View style={{ width: 450, height: 275 }}>
  <FastImage
    source={{ uri: 'http://example.com/huge-image-3600x2200.png' }}
    resizeMode="contain"
    resizeImageAndroid={{ width: 450, height: 275 }} // <-------
  />
</View>

I’ll submit this as a PR too, no guarantees if it’ll be accepted though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

tf.image.ResizeMethod | TensorFlow v2.11.0
Check out sessions from the WiML Symposium covering diffusion models with KerasCV, on-device ML, and more. Watch on demand.
Read more >
Image - React Native
The currently supported formats are png , jpg , jpeg , bmp , gif , webp , psd (iOS only). In addition, iOS...
Read more >
jax.image.resize - JAX documentation - Read the Docs
The method argument expects one of the following resize methods: ResizeMethod.NEAREST , "nearest". Nearest neighbor interpolation. The values of antialias ...
Read more >
tf.image.resize_images( images, size, method=ResizeMethod ...
tf.image.resize_images( images, size, method=ResizeMethod. ... By clicking “Post Your Answer”, you agree to our terms of service, ...
Read more >
Application.Resize method (Word) - Microsoft Learn
See also. Application Object. Support and feedback. Have questions or feedback about Office VBA or this documentation? Please see Office VBA ...
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