ImageCoder

open class ImageCoder : @unchecked Sendable

图片解码器,支持动图

SDWebImage

  • 单例模式

    Declaration

    Swift

    public static let shared: ImageCoder
  • 扩展系统UTType

    Declaration

    Swift

    public static var kUTTypeHEIC: CFString { get }
  • Undocumented

    Declaration

    Swift

    public static var kUTTypeHEIF: CFString { get }
  • Undocumented

    Declaration

    Swift

    public static var kUTTypeHEICS: CFString { get }
  • Undocumented

    Declaration

    Swift

    public static var kUTTypeWEBP: CFString { get }
  • 是否启用HEIC动图,因系统解码性能原因,默认为NO,禁用HEIC动图

    Declaration

    Swift

    open var heicsEnabled: Bool
  • Undocumented

    Declaration

    Swift

    public init()
  • 解析图片数据到Image,可指定scale

    Declaration

    Swift

    open func decodedImage(data: Data?, scale: CGFloat, options: [ImageCoderOptions : Any]? = nil) -> UIImage?
  • 编码UIImage到图片数据,可指定格式

    Declaration

    Swift

    open func encodedData(image: UIImage?, format: ImageFormat, options: [ImageCoderOptions : Any]? = nil) -> Data?
  • 获取图片数据的格式,未知格式返回undefined

    Declaration

    Swift

    open class func imageFormat(for imageData: Data?) -> ImageFormat
  • 图片格式转化为UTType,未知格式返回kUTTypeImage

    Declaration

    Swift

    open class func utType(from imageFormat: ImageFormat) -> CFString
  • UTType转化为图片格式,未知格式返回ImageFormat.undefined

    Declaration

    Swift

    open class func imageFormat(from utType: CFString?) -> ImageFormat
  • 图片格式转化为mimeType,未知格式返回application/octet-stream

    Declaration

    Swift

    open class func mimeType(from imageFormat: ImageFormat) -> String
  • 文件后缀转化为mimeType,未知后缀返回application/octet-stream

    Declaration

    Swift

    open class func mimeType(from fileExtension: String) -> String
  • 图片方向转为EXIF方向

    Declaration

    Swift

    open class func exifOrientation(from imageOrientation: UIImage.Orientation) -> CGImagePropertyOrientation
  • EXIF方向转为图片方向

    Declaration

    Swift

    open class func imageOrientation(from exifOrientation: CGImagePropertyOrientation) -> UIImage.Orientation
  • 图片数据编码为base64字符串,可直接用于H5显示等,字符串格式

    Declaration

    Swift

    open class func base64String(for imageData: Data?) -> String?
  • 图片base64字符串解码为数据,兼容格式:data:image/png;base64,数据

    Declaration

    Swift

    open class func imageData(for base64String: String?) -> Data?
  • 是否是向量图,内部检查isSymbolImage属性,iOS11+支持PDF,iOS13+支持SVG

    Declaration

    Swift

    open class func isVectorImage(_ image: UIImage?) -> Bool