Structures

The following structures are available globally.

  • ImageResource is a simple combination of downloadURL and cacheKey.

    When passed to image view set methods, Kingfisher will try to download the target image from the downloadURL, and then store it with the cacheKey as the key in cache.

    See more

    Declaration

    Swift

    public struct ImageResource: Resource
  • 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)
        }
    }
    
    See more

    Declaration

    Swift

    public struct FormatIndicatedCacheSerializer: CacheSerializer