Is it possible to use a custom CIFilter with an ImageRequest?
adamvnovak opened this issue · 2 comments
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.
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.
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.