CGImageProperties.h
列出了一堆用于指定EXIF和IPTC元数据的键。而且我可以成功设置JPEG图像的EXIF元数据:
- (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;
}
但是,我缺少如何指定XMP元数据,特别是XMP.GPano键。我尝试过这样的字典:
@{@"XMP": @{@"GPano": @{@"PosePitchDegrees": @20}}}
但它只是被忽略了。使用Core Graphics甚至可能吗?
最佳答案
您可以为此使用XMP SDK。这是一个强大的跨平台解决方案(Apple内部实际使用)。