ImageProcessor
public protocol ImageProcessor
An ImageProcessor
would be used to convert some downloaded data to an image.
-
Identifier of the processor. It will be used to identify the processor when caching and retrieving an image. You might want to make sure that processors with same properties/functionality have the same identifiers, so correct processed images could be retrieved with proper key.
Note
Do not supply an empty string for a customized processor, which is already reserved by theDefaultImageProcessor
. It is recommended to use a reverse domain name notation string of your own for the identifier.Declaration
Swift
var identifier: String { get }
-
process(item:options:)
Default implementationProcesses the input
ImageProcessItem
with this processor.Note
The return value should be
nil
if processing failed while converting an input item to image. Ifnil
received by the processing caller, an error will be reported and the process flow stops. If the processing flow is not critical for your flow, then when the input item is already an image (.image
case) and there is any errors in the processing, you could return the input image itself to keep the processing pipeline continuing.Note
Most processor only supports CG-based images. watchOS is not supported for processors containing a filter, the input image will be returned directly on watchOS.
Note
This method is deprecated. Please implement the version with
KingfisherParsedOptionsInfo
as parameter instead.Default Implementation
Undocumented
Declaration
Swift
@available(*, deprecated, message: "Deprecated. Implement the method with same name but with `KingfisherParsedOptionsInfo` instead.") func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image?
Parameters
item
Input item which will be processed by
self
.options
Options when processing the item.
Return Value
The processed image.
-
Processes the input
ImageProcessItem
with this processor.Note
The return value should be
nil
if processing failed while converting an input item to image. Ifnil
received by the processing caller, an error will be reported and the process flow stops. If the processing flow is not critical for your flow, then when the input item is already an image (.image
case) and there is any errors in the processing, you could return the input image itself to keep the processing pipeline continuing.Note
Most processor only supports CG-based images. watchOS is not supported for processors containing a filter, the input image will be returned directly on watchOS.
Declaration
Swift
func process(item: ImageProcessItem, options: KingfisherParsedOptionsInfo) -> Image?
Parameters
item
Input item which will be processed by
self
.options
The parsed options when processing the item.
Return Value
The processed image.
-
append(another:)
Extension methodAppends an
ImageProcessor
to another. The identifier of the newImageProcessor
will be\(self.identifier)|>\(another.identifier)
.Declaration
Swift
public func append(another: ImageProcessor) -> ImageProcessor
Parameters
another
An
ImageProcessor
you want to append toself
.Return Value
The new
ImageProcessor
will process the image in the order of the two processors concatenated.