Info | Value |
-------------------------|-------------------------------------|
Platform Name | ios
Platform Version | all
SDWebImage Version | The latest version
Integration Method | cocoapods
Xcode Version | Xcode 11
Repro rate | all the time
Repro with our demo prj | e.g. does it happen with our demo project?
Demo project link | e.g. link to a demo project that highlights the issue
When I use SDWebImageScaleDownLargeImages, this property turn a big picture into a very small picture which is not what we expect,
so I found the code:
thumbnailOptions[(__bridge NSString *)kCGImageSourceCreateThumbnailFromImageIfAbsent] = @(YES);
KCGImageSourceCreateThumbnailFromImageIfAbsent I think is the key problem,
Specifies whether a thumbnail should be automatically created for an image if a thumbnail isn't present in the image source file.
So I think we should replace KCGImageSourceCreateThumbnailFromImageIfAbsent with kCGImageSourceCreateThumbnailFromImageAlways。thanks!
See wiki: https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage#thumbnail-decoding-550
SDWebImageScaleDownLargeImages from v5.5.0, will translate to .imageThumbnailPixelSize. Which will use thumbnail decoding to create a smaller size.
By default, it should produce a image with 3966 x 3966 pixels, unless you modify the SDImageCoderHelper.defaultScaleDownLimitBytes
Or, maybe your image URL is a HEIC which contains a embed thumbnail image ? (Note only HEIF image format have this feature).
This may cause that Image/IO return back the embed thumbnail image, not what your set pixel size.
So I think we should replace KCGImageSourceCreateThumbnailFromImageIfAbsent with kCGImageSourceCreateThumbnailFromImageAlways。thanks!
Maybe you didn't read the source code carefully. The kCGImageSourceCreateThumbnailWithTransform already get applied. See: https://github.com/SDWebImage/SDWebImage/blob/5.8.0/SDWebImage/Core/SDImageIOAnimatedCoder.m#L204
Or, maybe your image URL is a
HEICwhich contains a embed thumbnail image ? (Note only HEIF image format have this feature).This may cause that Image/IO return back the embed thumbnail image, not what your set pixel size.
Yes, that's the case,ti`s a embed thumbnail image,
So how do I solve this problem, I want to use SDWebImageScaleDownLargeImages to solve the big picture problem.
Can you show the image URL, give a example so that I can debug with.
Maybe we can just add a backup logic: If the returned back CGImage from ImageIO, the size is much more smaller than the kCGImageSourceThumbnailMaxPixelSize we provided, then we use the full image for decoding
Actually, I think this is a bug of Apple. Because following the documentation:
Read it again, it should Produce the image from full image when the embed thumbnail image is smaller than the size we passed to the CGImageSourceCreateThumbnailAtIndex
Can you show the image URL, give a example so that I can debug with.
Maybe we can just add a backup logic: If the returned back CGImage from ImageIO, the size is much more smaller than the
kCGImageSourceThumbnailMaxPixelSizewe provided, then we use the full image for decodingActually, I think this is a bug of Apple. Because following the documentation:
Read it again, it should Produce the image from full image when the embed thumbnail image is smaller than the size we passed to the CGImageSourceCreateThumbnailAtIndex
http://resource-fat.7kid.com/7kid/moment/img/20206/55e26e85-a962-4d98-a51f-107b55911b24_6.jpg
example:
```NSString *url = @"http://resource-fat.7kid.com/7kid/moment/img/20206/55e26e85-a962-4d98-a51f-107b55911b24_6.jpg";
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubview:imageView];
[imageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil options:SDWebImageScaleDownLargeImages];
@ericdream Released 5.8.1