Creating a JPEG image with -[CIContext JPEGRepresentationOfImage:colorSpace:options] ignores options parameter

Originator:inbox
Number:rdar://27277088 Date Originated:11-Jul-2016
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 10.0 (14A5297c)
Classification: Reproducible:Always
 
Summary:
When creating a JPEG representation of a RAW file using CIContext, the options parameter appears to be ignored.

Steps to Reproduce:
1. Create a CIImage from a RAW file using the new CIRAWFilter functionality:

let image = CIFilter(imageURL: imageURL, options: [:])

2. Create a CIContext for exporting in the following way: 

let contextForSaving = CIContext(options: [kCIContextCacheIntermediates : false, kCIContextPriorityRequestLow : true, kCIContextWorkingFormat : NSNumber(int: kCIFormatRGBAh)])

3. Create an options dictionary in the following way: 

var outputOptions: [NSObject : AnyObject] = [kCGImageDestinationOptimizeColorForSharing: true,                                                   kCGImageDestinationLossyCompressionQuality : 0.8]

if image.extent.width.isFinite && image.extent.height.isFinite {
    outputOptions[kCGImageDestinationImageMaxPixelSize] = max(image.extent.width, image.extent.height) / 2.0
}

4. Generate a JPEG preview image in the following way:

let cs = CGColorSpaceCreateWithName(kCGColorSpaceDisplayP3)!
let imageData = contextForSaving.JPEGRepresentationOfImage(image, colorSpace: cs, options: outputOptions)



Expected Results:
I expect a JPEG image to be generated with the following properties:

1) The image is compressed according to the passed lossy compression quality.
2) The image is resized to the given size.

Actual Results:
1) The image compression value is ignored. The returned JPEG data is always the same length no matter which compression value is passed.

2) The image size value is ignored. The returned JPEG data always represents a full-size image.

Version:
iOS 10.0 (14A5297c)

Notes:


Configuration:
iPhone 6 GSM Unlocked

Comments


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!