使用PHPhotoLibrary保存照片时元数据丢失 [英] Metadata lost when saving photo using PHPhotoLibrary

查看:334
本文介绍了使用PHPhotoLibrary保存照片时元数据丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经使用ALAssetLibrary的writeImageToSavedPhotosAlbum:metadata:completionBlock将照片保存到相机胶卷中,但是现在在iOS 9.0中已弃用,因此我切换到了PHPhotoLibrary的版本,如下

I used to save a photo to the camera roll using ALAssetLibrary's writeImageToSavedPhotosAlbum:metadata:completionBlock, but that is now deprecated in iOS 9.0, so I switched to PHPhotoLibrary's version which looks like

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
    [PHAssetChangeRequest creationRequestForAssetFromImage:image];
}completionHandler:^(BOOL success, NSError *error) {
    if (success){
        NSLog(@"Image Saved!");
    } else {
        NSLog(@"Error: %@", error);
    }
}];

这会保存图像本身,但会丢失元数据(显示),并且在保存照片时找不到有关如何保存此数据的任何修复方法.任何帮助,将不胜感激. TYIA

This saves the image itself, but loses the metadata (exif ect) and I can't find any fixes of how to preserve this data when I save the photo. Any help would be appreciated. TYIA

推荐答案

我认为该方法

creationRequestForAssetFromImage:(UIImage *)image;

仅保存图像数据.它不包含元数据.

saves only image data. It doesn't include metadata.

如果要保存带有元数据的图像,可以按照以下步骤进行操作.

If you want to save a image with metadata, you can do it by the following step.

首先将图像保存在临时文件夹中,并将其路径保存为NSURL. 然后调用方法

First Save your image in temporary folder and get its path as NSURL. Then Call the method

creationRequestForAssetFromImageAtFileURL:(NSURL *)fileURL;

使用第一步中获得的NSURL.

with the NSURL you get in First step.

这篇关于使用PHPhotoLibrary保存照片时元数据丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆