SDImageTransformer

@protocol SDImageTransformer <NSObject>

A transformer protocol to transform the image load from cache or from download. You can provide transformer to cache and manager (Through the transformer property or context option SDWebImageContextImageTransformer).

Note

The transform process is called from a global queue in order to not to block the main queue.
  • For each transformer, it must contains its cache key to used to store the image cache or query from the cache. This key will be appened after the original cache key generated by URL or from user.

    Declaration

    Objective-C

    @required
    @property (readonly, copy, nonatomic, nonnull) NSString *transformerKey;

    Swift

    var transformerKey: String { get }

    Return Value

    The cache key to appended after the original cache key. Should not be nil.

  • Transform the image to another image.

    Declaration

    Objective-C

    - (nullable UIImage *)transformedImageWithImage:(nonnull UIImage *)image
                                             forKey:(nonnull NSString *)key;

    Swift

    func transformedImage(with image: UIImage, forKey key: String) -> UIImage?

    Parameters

    image

    The image to be transformed

    key

    The cache key associated to the image. This arg is a hint for image source, not always useful and should be nullable. In the future we will remove this arg.

    Return Value

    The transformed image, or nil if transform failed