4

CGImageProperties.h lists a bunch of keys to specify EXIF and IPTC metadata. And I can successfully set EXIF metadata for JPEG images:

- (NSData*)imageDataForImage:(UIImage*)image {
    NSDictionary *metadata = @{kCGImagePropertyExifDictionary: @{(NSString*)kCGImagePropertyExifLensModel: @"my lens"}};

    NSData* rawImageData = UIImageJPEGRepresentation(image, 1.0f);
    NSMutableData *imageData = [NSMutableData data];
    CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef) rawImageData, NULL);
    CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)imageData, kUTTypeJPEG, 1, NULL);
    CGImageDestinationAddImageFromSource(destination, source, 0, (__bridge CFDictionaryRef) metadata);
    CGImageDestinationFinalize(destination);
    CFRelease(source);
    CFRelease(destination);
    return imageData;
}

However, I'm missing how to specify XMP metadata, specifically the XMP.GPano keys. I tried a dictionary like this:

@{@"XMP": @{@"GPano": @{@"PosePitchDegrees": @20}}}

but it is simply ignored. Is this even possible using Core Graphics?

Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
  • Hi, I am facing the same issue, were you able to find a solution or is it simply not possible by using image destination? – Can Leloğlu Apr 07 '17 at 18:07

1 Answers1

0

You can use XMP SDK for this. It's a robust and cross-platform solution (actually used by Apple internally).

Yoav
  • 5,962
  • 5
  • 39
  • 61