Closed vkbest closed 2 years ago
You can use solutions based on your use case ? https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage
Response modifier, which pass you the (URLResponse, Data)
in, and you calculate and pass the (URLResponse, Data)
out. So you can modifiy the original image data at here.
Custom decoder, which means you can wrap you own decoder, if you use some custom encode && decode compression algorithm
Custom loader, final fork. Which let you re-write the SDWebImageDownloader by your hand. Powerful but considered at the last chance.
Hi thanks for the reply.
I tried implement a custom decoder, but is not called often, only some images trigger my decoder, so its not working to me. It's the first time I tried to implement a custom decoder, but I'm not sure this is the correct way, because I´m not really decoding/decompressing the image on any way, the images only are tiled and unordered making a similar feeling to a puzzle to avoid people downloading them but they are normal JPEG images, so its possible the custom decoder is only called on some images who requires special decoding, because the decoder is always called on the same images.
I´m not sure about the first thing you suggested, what do you mean about URLresponse? I didn't see anything about it on the documentation.
The third option looks much more work that implementing it with apple native apis.
EDIT: According the documentation I should conform the protocol SDWebImageCoder, but I can't find that protocol and I'm conforming SDImageCoder.
EDIT2: It's protocol SDImageIOCoder what is capturing the most images, some way to give priority to my custom decoder?
EDIT3: When the image is cached on disk, uses the original downloaded image.
For custom decoder, there are two way to load:
SDImageCodersManager
, which is the default shared instance, and manage order by each decoder one by one (ask the decoder canDecodeImageForData:
, if return YES, then decode it)sd_setImage(with: url, placeholderImage: something, options: [], context: [.imageCoder: MyCustomJPEGDecoder.shared])
, this context will only make MyCustomJPEGDecoder
works for this URL.When the image is cached on disk, uses the original downloaded image.
If you want to do this, it's a little hard, but possible.
Your use case maybe:
For 1, there are something called SDWebImageCacheSerializer. Just call image.sd_imageData(as: .JPEG)
and return it.
Thanks
I implemented SDWebImageCacheSerializer and its working as should it
Sorry for my poor English.
I'm using WebImage with SwiftUI on AppleTV.
The thing is, for security reasons, we are obfuscating images (I´m not sure if this word is correct), so the images on the server have different size to the real image and they are altered to make harder people download them, on web we are using Javascript and canvas to rebuild the real image from the altered image in server.
So my question, it's possible to download the image with WebImage, alter it and render with WebImage?
Thanks