我正在尝试使用地理标记信息更新 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;
}
最佳答案
看看 libexif:http://libexif.sourceforge.net/
您可能需要使用以下方法将图像的字节数据传递给库
UIImageJPEGRepresentation(image, quality) bytes]
关于ios - 使用 EXIF/geotag 信息更新内存中的 iOS UIImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9051326/