Skip to content

What does SDWebImageDecoder do? #1173

@onmyway133

Description

@onmyway133

I see that by default, SDWebImage use SDWebImageDecoder to decompress UIImage. AFNetworking also does this with itsImageSerializer

I'm about to detect the size and resize the image, in this callback

- (UIImage *)imageManager:(SDWebImageManager *)imageManager
 transformDownloadedImage:(UIImage *)image
                  withURL:(NSURL *)imageURL

Size

I see that the size (in byte) of the original image from the server and image saved on disk are the same. So this "decompression" does not increase the file size

Resize

I follow Image Resizing Techniques, using UIGraphicsBeginImageContextWithOptions & UIImage -drawInRect: approach, with half CGRect as the original transformDownloadedImage

However, I see that

  • The resized image is the same size (in dimension) as the transformDownloadedImage
  • The size (in byte) of the resized image is of much smaller size than the transformDownloadedImage (80KB compared to 2.5MB)

Size (in byte) detection

I use Get size of a UIImage (bytes length) not height and width
However, I see that

  • The size (in byte) is not correct

If I use normal [UIImage imageNamed:"file_name"], then all is correct. So there must be something about the "SDWebImageDecoder decompression" that make all of this fails, or my images contain unrelated image meta data

I'd like to know, thanks

Activity

onmyway133

onmyway133 commented on Jun 11, 2015

@onmyway133
Author

So it has nothing to do with decompression, it is because the images contain unused meta data

Resize

  • The original image is 290x290, then I specify half CGRect (which is 145x145), but my device scale is 2, so the result image is 290x290
  • UIGraphicsBeginImageContextWithOptions & UIImage -drawInRect: strips the meta data out, so the resized size is much decreased

Size (in byte) detection

The result size does not take meta data into account

modified the milestones: 4.0.0, Future, 3.7.3 on Jun 24, 2015
bpoplauschi

bpoplauschi commented on Jun 29, 2015

@bpoplauschi
Member

@onmyway133 why did you close this?

mythodeia

mythodeia commented on Jun 29, 2015

@mythodeia
Contributor

@bpoplauschi i think he answered his own question regarding the size of the image before and after the decoding

onmyway133

onmyway133 commented on Jun 29, 2015

@onmyway133
Author

@bpoplauschi @mythodeia I see that the problem has nothing to do with SDWebImageDecoder, it is just misunderstanding the usage of image. So I think it is enough :] Also, I sum up in this Understanding SDWebImage – Decompression

bpoplauschi

bpoplauschi commented on Jul 1, 2015

@bpoplauschi
Member

Great post. Thanks for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bpoplauschi@mythodeia@onmyway133

        Issue actions

          What does SDWebImageDecoder do? · Issue #1173 · SDWebImage/SDWebImage