Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to apply processors to placeholder #823

Open
ertembiyik opened this issue Nov 10, 2024 · 1 comment
Open

No way to apply processors to placeholder #823

ertembiyik opened this issue Nov 10, 2024 · 1 comment

Comments

@ertembiyik
Copy link

ertembiyik commented Nov 10, 2024

There is currently no way (or I haven't found it) to apply processors to placeholders and cache them.
It could be useful for cases where the loaded image and placeholder should have the same corner radius, blur, size, etc.

Also as an addition, it would be grate to add a localImage option to ImageRequest for cases where you want to use an already existing image with the power of processors in Nuke (I think under the hood it could be an alias to placeholder, but a more friendly higher api for the ones who try to find how to apply processors to an already existing image).

The new initializer for ImageRequest could look something like this:

public init(
        id: String,
        image: PlatformImage,
        processors: [any ImageProcessing] = [],
        priority: Priority = .normal,
        options: Options = [],
       userInfo: [UserInfoKey: Any]? = nil
    )
@kean
Copy link
Owner

kean commented Nov 15, 2024

Hey, you can apply a processor to a placeholder or any other image directly:

let processor = ImageProcessors.Resize(size: CGSize(width: 400, height: 400), unit: .pixels, contentMode: .aspectFill)
let output = processor.process(image)

I'd suggest then caching the processed images manually. Would that cover your use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants