4

I want to duplicate an image from the Photo Library but I want to check in the future if I already have imported this image.

Immagine this scenario.

  1. I have a photo in my Photo Library.
  2. I import it in my app by making a copy of it.
  3. I remove this photo from my library.
  4. At a later time I reinsert this picture to my photo library (Same photo from iPhoto, just didn't synch it's album before and I have now)

Is there a unique identifier that I can use to compare the two pictures? is the URL unique? Or do I have to look into the metadata and try to match it? If so, what would you suggest? Created Data and location? Just created Date? Size?

Thanks for your advice.

Leonardo Amigoni
  • 2,237
  • 5
  • 25
  • 35

1 Answers1

3

Observations

I've been working with similar functionality, so this is what I know:

  • Each photo inserted into the photo library will have a unique URL (this means if you insert an image, delete it, then insert it again, even if it is the same image, it will have a new URL).
  • There is no straight forward way of knowing whether an image is a duplicate of a previous image or not.
  • I don't think you are trying to do this, but I will warn you that you cannot delete an image programmatically from the iPhone Photo library.

Solutions

I really only have one way of handling this: Create a hash of the photo and store the hash somewhere. If the photo inserted is the exact same photo as before, it should give you the same hash. You can use that hash comparison to determine if you are using the same photo or not. This is the method that I am using and it seems to work reliably for the most part. I have noticed some discrepancies, but these usually involve my work hashing the files before they are added to the photo library (I have noticed that the saved photo can be different from the photo that is being saved).

I hope this information helps. Let me know if I've missed anything or you notice different results in your work.

groomsy
  • 4,945
  • 6
  • 29
  • 33
  • Thanks for your observations. Very helpful. The fact that if you delete an image from the library and if you add it again it's different is a really a pity but I guess necessary. They must handle the case of the same file with the same name and the same date etc. Fortunately I don't have to try to match photos it would really be a pain but the technique you have described seems the one I would have gone for. I was worried that URLs were changing if you just update the library but they don't which is great. Thanks again. – Leonardo Amigoni Aug 31 '12 at 07:42