简体   繁体   中英

How to uniquely identify UIImage picked from UIImagePickerController?

I have picked an image from photo library using UIImagePickerController . Now I want to save that image in documents folder. I have also got the url of that folder.

Problem is what name should I assign to image so that I can uniquely identify it? If I add date time stamp with image name, then user can save two same images from photos library with different names in documents folder which is undesirable.

Or is there some logic to compare two UIImage s to check if it already exists?

一种方法是使用文件url的哈希-您可以在https://github.com/rs/SDWebImage/blob/master/SDWebImage/SDImageCache.m中看到实现

For comparing two images, if they are the same or not you can try this.

if([UIImagePNGRepresentation(image1) isEqualToData:UIImagePNGRepresentation(image2)])
{
 NSLog(@"Same images");
}

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