FormatIndicatedCacheSerializer

public struct FormatIndicatedCacheSerializer: CacheSerializer

FormatIndicatedCacheSerializer let you indicate an image format for serialized caches.

It could serialize and deserialize PNG, JEPG and GIF images. For image other than these formats, a normalized pngRepresentation will be used.

Example:

 private let profileImageSize = CGSize(width: 44, height: 44)

 private let imageProcessor = RoundCornerImageProcessor(
     cornerRadius: profileImageSize.width / 2, targetSize: profileImageSize)

 private let optionsInfo: KingfisherOptionsInfo = [
     .cacheSerializer(FormatIndicatedCacheSerializer.png), 
     .backgroundDecode, .processor(imageProcessor), .scaleFactor(UIScreen.main.scale)]

 extension UIImageView {
    func setProfileImage(with url: URL) {
        // Image will always cached as PNG format to preserve alpha channel for round rect.
        _ = kf.setImage(with: url, options: optionsInfo)
    }
}