问题
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