HEIC encoding of CIImage failing with iOS14

246 views Asked by At

I have following simple code that is failing on iOS14 (was working fine with iOS13).

The code converts a CIImage object to heif representation.

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] )
    })
}

0

There are 0 answers