HEIC encoding of CIImage failing with iOS14

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

The code converts a CIImage object to heif representation.

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

I encountered a very similar bug and I found a workaround. Can you try context.heifRepresentation(of: image.settingAlphaOne(in: image.extent), …) and see if that works?
HEIC encoding of CIImage failing with iOS14
 
 
Q