WebPProcessor.swift 855 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // WebPProcessor.swift
  3. // Pods
  4. //
  5. // Created by yeatse on 2016/10/19.
  6. //
  7. //
  8. import Foundation
  9. import Kingfisher
  10. public struct WebPProcessor: ImageProcessor {
  11. public static let `default` = WebPProcessor()
  12. public let identifier = "com.yeatse.WebPProcessor"
  13. public init() {}
  14. public func process(item: ImageProcessItem, options: KingfisherParsedOptionsInfo) -> KFCrossPlatformImage? {
  15. switch item {
  16. case .image(let image):
  17. return image
  18. case .data(let data):
  19. if data.isWebPFormat {
  20. return KingfisherWrapper<KFCrossPlatformImage>.image(webpData: data, scale: options.scaleFactor, onlyFirstFrame: options.onlyLoadFirstFrame)
  21. } else {
  22. return DefaultImageProcessor.default.process(item: item, options: options)
  23. }
  24. }
  25. }
  26. }