6

I want to store the images to photo gallary. But if images are already available at photo gallary then how to distinguish for whether imgaes are already exists or not? I didnt find property like unique identifier or should i compare by taking data in the form of NSdata?

thanks..

Swapnil
  • 1,858
  • 2
  • 22
  • 49

2 Answers2

1

You can maintain a dictionary of hashes for each the image in the photo gallery, and then show only additional images who do not hashes are not present in the dictionary

As a reminder, you can check for an object in a dictionary by doing:

if ([myDictionary objectForKey:variableStoringImageHash] == nil) {
   //No such image present
}
else {
   //image is present
}

For a bit about hashing an image, this might help: iPhone: fast hash function for storing web images (url) as files (hashed filenames)

Community
  • 1
  • 1
Eitan
  • 1,308
  • 3
  • 15
  • 32
0

I am not sure if what eitan27 says will work so as an alternative I would say that your best hope is comparing NSData objects. But this as you can see will become very tedious as there will be n number of images in library and comparing each one for repetition does't make sense , still if you want to compare data you look at this answer which will give you a fraction of how much the data is matching.

Community
  • 1
  • 1
Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115