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

Is it possible to use a custom CIFilter with an ImageRequest? #758

Closed
adamvnovak opened this issue Feb 27, 2024 · 2 comments · Fixed by #777
Closed

Is it possible to use a custom CIFilter with an ImageRequest? #758

adamvnovak opened this issue Feb 27, 2024 · 2 comments · Fixed by #777
Labels
improvement Non-functional change that improves existing functionality

Comments

@adamvnovak
Copy link

adamvnovak commented Feb 27, 2024

I use a custom LUT filter like so:

let lutFilter = colorCubeFilterFromLUT(imageName: "K64LUT")
lutFilter!.setValue(incrementallyFilteredImage, forKey: kCIInputImageKey)
incrementallyFilteredImage = lutFilter?.outputImage

But it seems like the processors on ImageRequest don't allow you to pass a filter in, you can only identify existing filters.

return ImageRequest(url: url, 
            processors: [
                ImageProcessors.Resize(width: 500),
                ImageProcessors.CoreImageFilter.init(name: <#T##String#>, parameters: <#T##[String : Any]#>, identifier: <#T##String#>)
            ]
)

Is it not possible to cache an image with a custom CIFilter as of now?

What could be a workaround? Should I cache the load the image using ImagePipeline, then immediately apply my custom filter, and then override the saved data in the cache? I would like instant access to the image with the filter later on.

@kean kean added question improvement Non-functional change that improves existing functionality and removed question labels Mar 5, 2024
@kean
Copy link
Owner

kean commented Mar 5, 2024

Hey, @adamvnovak. I would suggest introducing a new initializer to CoreImageFilter that would support CIFillter. I'll be happy to get it reviewed and merged – it's going to be a great addition.

@kean kean mentioned this issue Apr 20, 2024
@kean kean closed this as completed in #777 Apr 21, 2024
@kean
Copy link
Owner

kean commented Apr 24, 2024

I added the following new API in Nuke 12.6:

let filter = try XCTUnwrap(CIFilter(name: "CISepiaTone", parameters: nil))
let processor = ImageProcessors.CoreImageFilter(filter, identifier: "test")

// Or
ImageRequest(..., processors: [.coreImageFilter(filter, identifier: "test")])

The identifier is a required parameter as it's needed for caching purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Non-functional change that improves existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants