Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDWebImage process images before caching

I fetch a lot of images from the web, and they are all kind of sizes - they can be big, small etc..

So I can resize them when I display them in the cell but this is inefficient. It's way better to resize them after SDWebImage have download them and cache them resized, instead of storing large images on disk and resize them for every cell.

So how can I do this with SDWebImage, or I have to hack a bit onto the class?

like image 560
Devfly Avatar asked Oct 17 '12 06:10

Devfly


2 Answers

SDWebImage developer Olivier Poitrey answered this question for me here.

You have to implement the SDWebImageManagerDelegate protocol and then set it as the shared manager's delegate like this:

SDWebImageManager.sharedManager.delegate = self;

using the imageManager:transformDownloadedImage:withURL: instance method.

More information.

Worked perfectly for me.

like image 103
Jayson Avatar answered Nov 08 '22 20:11

Jayson


I had the same problem as you, and tried tweaking SDWebImage first, but ended up building my own component that solved the problem. You can take take a look at it here : https://github.com/adig/RemoteImageView

like image 38
adig Avatar answered Nov 08 '22 19:11

adig