【发布时间】:2012-01-29 06:14:15
【问题描述】:
我正在尝试使用地理标签信息更新UIImage。我查看了Saving Geotag info with photo on iOS4.1,在那里我找到了对NSMutableDDictionary+ImageMetadata category 的引用。但是,我不想保存到相册,而是有一个UIImage 可以传递。
以下代码似乎复制了太多图像副本,需要链接所有这些框架:CoreImage、AssetsLibrary、CoreMedia、ImageIO。
有没有比UIImage -> CIImage -> CGImage -> UIImage 更有效的方法可以获取设置 EXIF 数据所需的属性 NSDictionary?
- (UIImage *)updateImage:(UIImage *)image location:(CLLocation *)location dateOriginal:(NSDate *)dateOriginal
{
NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithDictionary:[image.CIImage properties]];
// uses https://github.com/gpambrozio/GusUtils
[properties setLocation:location];
[properties setDateOriginal:dateOriginal];
CIImage *tempImage = [[CIImage alloc] initWithImage:image options:properties];
CIContext *context = [CIContext contextWithOptions:nil];
UIImage *updatedImage = [UIImage imageWithCGImage:[context createCGImage:tempImage fromRect:tempImage.extent]];
return updatedImage;
}
【问题讨论】: