You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Limits scale down to 24MB.
SDImageCoderHelper.defaultScaleDownLimitBytes = 24 * 1_024 * 1_024
When I get an animated image data that weighs 1.8 MB, the quality is severely degraded, and if I saw correctly my final image was 0.5 MB. I tried to play around with setting the value and in the end I got an image of 7200 bytes with the 1 MB limit set.
Am I misunderstanding the expected behavior? Because it looks like a bug to me. Since it is strange that by setting the limit to 24 MB I get image quality degradation and image size reduction when its image data size is only 1.77 MB.
Also maybe you can tell me why when I try to download a heavy image and several small images, if the heavy image was added earlier, I don't get a response for the small images until the large one is downloaded? (It is important to note that I am considering the case of downloading an image from disk or over the network, only in these cases this happens).
Image Data Size (JPEG/WebP/PNG)
!=
Image RAM (buffer) size (CGImage/UIImage/CIImage)
Image Data are "Compressed Format" of a vector, vector element is pixel (normally just Pixel8888, a 3/4 component uint8_t, or just think as a uint24_t/uint32_t)
The calculation is correct actually. Image Buffer Size on RAM is just
BytesPerPixel * PixelCont
= BytesPerPixel * PixelPerFrame * FrameCount
= BytesPerPixel * ImageWidth * ImageHeight * FrameCount
= BytesPerComponent * ComponentCount * ImageWidth * ImageHeight * FrameCount, Component == 4 if contains alpha, else 3 for RGB
= sizeof(PixelType) * ComponentCount * ImageWidth * ImageHeight * FrameCount, if you use RGBA8888, the BytesPerComponent is 8 (sizeof uint8_t)
Activity
dreampiggy commentedon Dec 3, 2024
Image Data Size (JPEG/WebP/PNG)
!=
Image RAM (buffer) size (CGImage/UIImage/CIImage)
Image Data are "Compressed Format" of a vector, vector element is pixel (normally just Pixel8888, a 3/4 component
uint8_t, or just think as auint24_t/uint32_t)The calculation is correct actually. Image Buffer Size on RAM is just
BytesPerPixel * PixelCont=
BytesPerPixel * PixelPerFrame * FrameCount=
BytesPerPixel * ImageWidth * ImageHeight * FrameCount=
BytesPerComponent * ComponentCount * ImageWidth * ImageHeight * FrameCount, Component == 4 if contains alpha, else 3 for RGB=
sizeof(PixelType) * ComponentCount * ImageWidth * ImageHeight * FrameCount, if you use RGBA8888, the BytesPerComponent is 8 (sizeof uint8_t)dreampiggy commentedon Dec 3, 2024
This
scaleDownLimitBytescan be set forPer-Image-Request, not that global control. So you can limit a larger bytes for animated imagePass
SDWebImageContextImageScaleDownLimitBytesonloadImageWithURLorsetImageWithURLAPI from the top-levelAnother addition of behavior is that we separate the
limitBytesforstatic imageandanimated image, they can have different scale down limit bytes.dreampiggy commentedon Dec 3, 2024
⬆️ If you're interested in the feature above, leave comments here
When finished, I can submit a feature request to https://github.com/SDWebImage/SDWebImage and implement it