Coil: Coil does not upscale resources

Created on 29 Aug 2019  路  6Comments  路  Source: coil-kt/coil

Describe the bug
When I download a resource from URL and its size is smaller than the requested size in the GetRequestBuilder, result is not upscaled. On the contrary, when I set a smaller size inside my GetRequestBuilder, the resource is correctly downscaled.

To Reproduce
Download this image using Coil.get(url) { size(256, 256) }

Expected behavior
I would expect to have a resulting drawable of 256x256 instead of the 24x24 provided

Library version
0.6.1

bug

Most helpful comment

@r4phab This is currently intended behaviour. Coil avoids loading images at a larger size than necessary to conserve memory. This behaviour is also fairly core to how Coil handles the dynamic sampling crossfade effect.

If you need to upscale an image, I'd recommend creating a Transformation that scales the input Bitmap. If you're drawing to a Canvas, you can also scale the Bitmap using drawBitmap.

All 6 comments

@r4phab This is currently intended behaviour. Coil avoids loading images at a larger size than necessary to conserve memory. This behaviour is also fairly core to how Coil handles the dynamic sampling crossfade effect.

If you need to upscale an image, I'd recommend creating a Transformation that scales the input Bitmap. If you're drawing to a Canvas, you can also scale the Bitmap using drawBitmap.

Quick update on this issue. I probably won't have time to address this for 0.8.0, but will try to tackle it the subsequent release. The plan is to add ImageLoader-specific and Request-specific config flags to disable this optimization.

Thank you @colinrtwhite for your prompt response and your explanations

This is now fixed in master. To get the fix asap you can depend on 0.9.0-SNAPSHOT.

See https://github.com/coil-kt/coil/pull/183 for more info on the implementation, but TLDR Coil will now ensure the loaded image's dimensions are as requested for custom targets and Coil.get.

@colinrtwhite just to know, when are you planning to release 0.9.0 ? Just to know if I need to use some workarounds or wait a little bit

@bishiboosh I'd estimate in the next 1-2 weeks. Definitely before December 25th.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ZacSweers picture ZacSweers  路  4Comments

vegeta2102 picture vegeta2102  路  6Comments

ghost picture ghost  路  4Comments

RubenGonzalezGonzalez picture RubenGonzalezGonzalez  路  6Comments

Starscream9559 picture Starscream9559  路  7Comments