CIContext jpegRepresentation doesn't work if kCGImageDestinationLossyCompressionQuality option is added

Originator:yakov.shkolnikov
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: "https://www.adobe.com/content/dam/cc/us/en/creativecloud/file-types/image/raster/jpeg-file/OG-1200x800-jpeg.jpg")!)
let ciImage = CIImage(data: imageData)!
let data = CIContext().jpegRepresentation(
    of: ciImage,
    colorSpace: CGColorSpaceCreateDeviceRGB(),
    options: [kCGImageDestinationLossyCompressionQuality as CIImageRepresentationOption: 1]
)!
let newImage = UIImage(data: data)
print(newImage)
```
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.

Comments

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 bugreport.apple.com 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!