Metadata lost when saving photo using PHPhotoLibrary

别等时光非礼了梦想. 提交于 2019-12-12 14:57:53

问题


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);
    }
}];

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


回答1:


I think the method

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.

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

creationRequestForAssetFromImageAtFileURL:(NSURL *)fileURL;

with the NSURL you get in First step.



来源:https://stackoverflow.com/questions/38212430/metadata-lost-when-saving-photo-using-phphotolibrary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!