Comments (4)
The decoding happens using ImageDecoding
objects. I suggest adding the decryption step during that stage, and then invoking the built-in decoders. See https://kean-docs.github.io/nuke/documentation/nuke/image-decoding for more information.
from nuke.
Ah, that sounds promising!
Thanks for making such a great library. It is amazing!
Edit: I can use the userInfo dictionary for the key I suppose!
ImagePipeline.shared = ImagePipeline {
$0.makeImageDecoder = { context in
if let key = context.request.userInfo["key"] as? Data {
var copy = context
copy.data = try! decrypt(data: context.data, using: key)
return ImageDecoderRegistry.shared.decoder(for: copy)
}
return ImageDecoderRegistry.shared.decoder(for: context)
}
}
When creating the image pipeline, I set the makeImageDecoder
closure to check for a given key and then decode the data. The data is properly decoded, but the image state says Failed to decode image data using decoder Nuke.ImageDecoders.Default
even though I can check with the debugger that the default decoder can in fact decode the image.
from nuke.
Failed to decode image data using decoder Nuke.ImageDecoders.Default even though I can check with the debugger that the default decoder can in fact decode the image.
The code that you provided looks good.
Btw, makeImageDecoder
is called on the pipeline's background queue, so I think it's an OK trade-off performance-wise to put it there.
from nuke.
Sorry for the very late responses here.
So It seems Nuke doesn't get me the correct decoder with my code. If I add a debug line (the one after the comment)
$0.makeImageDecoder = { context in
if let key = context.request.userInfo["key"] as? Data {
var copy = context
copy.data = try! Cryptor.default.decrypt(data: context.data, using: .init(data: key))
// this gets me to the correct image…
let image = try! Nuke.ImageDecoders.Default().decode(copy.data)
return ImageDecoderRegistry.shared.decoder(for: copy)
}
return ImageDecoderRegistry.shared.decoder(for: context)
}
then I can see that the image is correctly decoded. returning the ImageDecoderRegistry.shared.decoder(for: copy)
though doesn't seem to work (although the error message that I receive
Failed to decode image data using decoder Nuke.ImageDecoders.Default
seems to indicate it wants to pick the right one anyway.
Do you have any suggestions of where I should be looking?
from nuke.
Related Issues (20)
- Potential Memory Issue when using any processors such as Resize HOT 11
- Custom DataLoader without native URL cache HOT 1
- JPG not resizing, just black HOT 2
- Xcode warning: IO on main thread HOT 1
- Add dataTask that is similar to imageTask HOT 2
- Skip decompression for .png images and other uncompressed formats HOT 1
- Error resizing PNG-8 images HOT 3
- Authorization header HOT 2
- Image scaling bug HOT 11
- Is there any way to apply transition to placeholder? HOT 1
- startImageTask causing memory issue and crashing the app HOT 3
- Error -17102 decompressing image -- possibly corrupt HOT 4
- Feature Request: Logging for image request HOT 4
- Question: Task cancellation HOT 2
- Question: How to force some images to be cached on disk? HOT 2
- NukeUI repo has gone missing HOT 2
- Request for Nuke 11+ Support in Cocoapods HOT 1
- Potential leak in ImagePipelineDelgate HOT 4
- Does not support .ico images
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuke.