CIContext jpegRepresentation doesn't work if kCGImageDestinationLossyCompressionQuality option is added

Number:rdar://FB13576870 Date Originated:Feb 2, 2024
Status:Fixed Resolved:Feb 7, 2024
Product:iOS Product Version:17.4 beta
Classification: Reproducible:
The issue is reproduced in iOS 17.4 beta, but works fine in 17.3 public release. jpegRepresentation doesn't work properly if kCGImageDestinationLossyCompressionQuality option is added. The following code: ```
let imageData = try! Data(contentsOf: URL(string: "")!)
let ciImage = CIImage(data: imageData)!
let data = CIContext().jpegRepresentation(
    of: ciImage,
    colorSpace: CGColorSpaceCreateDeviceRGB(),
    options: [kCGImageDestinationLossyCompressionQuality as CIImageRepresentationOption: 1]
let newImage = UIImage(data: data)
produces following output:
createImageAtIndex:1660: *** ERROR: createImageAtIndex[0] - 'JPEG' - failed to create image [-59]
CGImageSourceCreateImageAtIndex:4491: *** ERROR: CGImageSourceCreateImageAtIndex[0] - 'JPEG' - failed to create image [-59] 
and works just fine by removing options.


Fixed in iOS 17.4 Beta 2

By yakov.shkolnikov at Feb. 7, 2024, 5:48 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!