Get back UIImage data after saving it to photo Library in iOS

只谈情不闲聊 提交于 2019-12-06 10:42:37
Avt

Your image is compressed to JPEG before it is saved to photo album. And is decompressed when you are loading it. JPEG is lossy compression. So when you are comparing pixel-data you have differences between original image and compressed/decompressed.

To save lossless try following:

+ (void)saveImageData:(NSData *)data {
    ALAssetsLibrary *assetLib = [[[ALAssetsLibrary alloc] init] autorelease];
    [assetLib writeImageDataToSavedPhotosAlbum:data metadata:nil completionBlock:nil];
}

For more information about lossless saving/loading to/from photo album please read this thread Saving to/getting JPEG from user gallery without recompression

You can't manage a file compare process with saved photos album images because, It automatically embeds few more details with your saved image such as details about location, time etc... when you are saving an image to the photo library. So it will not be same as your input image after the retrieval.

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