Does [CIContext writeJPEGRepresentationOfImage:(CIImage*)image ...] prune certain EXIF tags from the image attachments dictionary?

I'm using [CIContext writeJPEGRepresentationOfImage:(CIImage*)image ...] to export a CIImage to a JPEG file, which works fine.

However, when attempting to attach custom EXIF metadata to the image, not all of my custom EXIF tags end up in the JPEG file.


In the (simplified) example below, the "UserComment" EXIF tag ends up getting exported, but the "CustomRendered" EXIF tag does not (!):


CVImageBufferRef imageBuffer = [... our image buffer ...];
NSMutableDictionary* customImageAttachments = [... obtained from a CMSampleBufferRef ...];
customImageAttachments[(__bridge NSString*)kCGImagePropertyExifDictionary][(__bridge NSString*)kCGImagePropertyExifCustomRendered] = @"1"; // EXIF tag will NOT end up in the exported JPEG file.
customImageAttachments[(__bridge NSString*)kCGImagePropertyExifDictionary][(__bridge NSString*)kCGImagePropertyExifUserComment] = @"QWERTY12345"; // EXIF tag will end up in the exported JPEG.
CIContext* context = [CIContext context];
CIImage* inputImage = [CIImage imageWithCVImageBuffer:imageBuffer options:@{kCIImageProperties: customImageAttachments}];
NSURL *temporaryFileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg", [[NSUUID UUID] UUIDString]]]];
[context writeJPEGRepresentationOfImage:inputImage
  toURL:temporaryFileURL
  colorSpace:CGColorSpaceCreateWithName(kCGColorSpaceSRGB)
    options:@{ (__bridge NSString*)kCGImageDestinationLossyCompressionQuality : @1.0f}
  error:nil];
// (Not shown: Create a new PHAsset from JPEG at temporaryFileURL using PHAssetCreationRequest)
[[NSFileManager defaultManager] removeItemAtURL:temporaryFileURL error:nil];


I checked the exported JPEG file with both exiv2 and exiftool, and the "CustomRendered" tag is definitely missing from the file.

Is there a specific reason for this? Are certain EXIF tags deleted before export? If yes, which ones?

Replies

Forgot to mention: I've been testing this on iOS 10 beta 7.

I believe there was bug as far back as iOS 8 that made them unreliable...perhaps that's still the case? Did you file one to see what came back?