You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm trying to extract some data from a processor in the .data case and pass it along to the .image case. For example, I have following code:
struct CustomProcessor: ImageProcessor {
let identifier: String
func process(item: ImageProcessItem, options: KingfisherParsedOptionsInfo) -> KFCrossPlatformImage? {
switch item {
case .image(let image):
// want to use metadata here
// do something
return image
case .data:
// I want to extract some metadata from the image here
let src = CGImageSourceCreateWithData(data as CFData, nil)
// how can I use this in the .image case when we pass back the data to the DefaultImageProcessor?
let metadata = CGImageSourceCopyMetadataAtIndex(src!, 0, nil)
return (DefaultImageProcessor.default |> self).process(item: item, options: options)
}
}
}
Any help would be appreciated!
The text was updated successfully, but these errors were encountered:
I am not sure if it is an abusing of ImageProcessor, but how about these code?
structMetaDataProcessor:ImageProcessor{letmetaData:MetaData// can be an int, or anything else you can customize.varidentifier:String{/* It is better to return a value can be identified by the metaData. */}func process(item:ImageProcessItem, options:KingfisherParsedOptionsInfo)->KFCrossPlatformImage?{
switch item {case.image(let image):// You now have the correct metaData here.return image
case.data:// You can even leave empty, this case won't be called.returnUIImage()}}}structCustomProcessor:ImageProcessor{letidentifier:Stringfunc process(item:ImageProcessItem, options:KingfisherParsedOptionsInfo)->KFCrossPlatformImage?{
switch item {case.image(let image):return image
case.data:letsrc=CGImageSourceCreateWithData(data asCFData,nil)letmetadata=CGImageSourceCopyMetadataAtIndex(src!,0,nil)letnext=MetaDataProcessor(metaData: metadata)return(DefaultImageProcessor.default |> next).process(item: item, options: options)}}}
And in the use case, make sure you set the CustomProcessor as the first of the .processor option.
Hello, I'm trying to extract some data from a processor in the .data case and pass it along to the .image case. For example, I have following code:
Any help would be appreciated!
The text was updated successfully, but these errors were encountered: