我正在使用ALAssetsLibrary将任意UIImage写入相机胶卷:
NSMutableDictionary exifAttachments = [[NSMutableDictionary alloc] init];
}
[exifAttachments setValue:[NSNumber numberWithInt:imgWidth] forKey:(NSString*)kCGImagePropertyExifPixelXDimension]; //OK
[exifAttachments setValue:[NSNumber numberWithInt:imgHeight] forKey:(NSString*)kCGImagePropertyExifPixelYDimension]; //OK
[exifAttachments setValue:[NSDate date] forKey:(NSString*)kCGImagePropertyExifDateTimeDigitized]; //NOT OK
_assetsLibrary writeImageToSavedPhotosAlbum:[img CGImage] metadata:exifAttachments completionBlock:^(NSURL *assetURL, NSError *error) {
NSLog(@"Big error: %@", [error description]);
}];
这适用于某些参数,但所有与相机相关的参数(例如“时间数字化”,“白平衡”等)都会被忽略。 我的代码有问题吗?如何手动添加特定于摄像机的EXIF元数据?
[编辑] 我自己找到了解决方案。对于所有EXIF数据,必须添加child-NSDictionary:
[exifAttachments setObject:[NSMutableDictionary dictionaryWithCapacity:1] forKey:(NSString*)kCGImagePropertyExifDictionary];
向这个孩子添加数据时,一切正常。
此致
答案 0 :(得分:0)
见上面的编辑:
[exifAttachments setObject:[NSMutableDictionary dictionaryWithCapacity:1] forKey:(NSString*)kCGImagePropertyExifDictionary];