简体   繁体   中英

Metadata lost when saving photo using 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);
    }
}];

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM