我有以下在 iOS14 上失败的简单代码(在 iOS13 上运行良好)。
该代码将 CIImage 对象转换为 heif 表示。
func encodeImageToHeif(_ image: CIImage ) -> Data? {
return autoreleasepool(invoking: { () -> Data? in
let color = CGColorSpace(name: CGColorSpace.sRGB)
let context = CIContext()
return context.heifRepresentation(of: image,
format: CIFormat.RGBA8,
colorSpace: color!,
options: [kCGImageDestinationLossyCompressionQuality
as CIImageRepresentationOption : 0.2] )
})
}