【问题标题】:Updating an in-memory iOS UIImage with EXIF/geotag information使用 EXIF/地理标签信息更新内存中的 iOS UIImage
【发布时间】: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;
}

【问题讨论】:

    标签: ios image uiimage exif


    【解决方案1】:

    看看 libexif:http://libexif.sourceforge.net/

    您可能需要使用

    将图像的字节数据传递给库
    UIImageJPEGRepresentation(image, quality) bytes]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-14
      相关资源
      最近更新 更多