Giter VIP home page Giter VIP logo

Comments (4)

kean avatar kean commented on August 26, 2024 1

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.

tkrajacic avatar tkrajacic commented on August 26, 2024

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.

kean avatar kean commented on August 26, 2024

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.

tkrajacic avatar tkrajacic commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.