views:

266

answers:

2

When I get a new image taken by the user with the camera and save its checksum, when the user later reloads that same image from the camera roll, the checksum is different. Could this be because the image saved in camera roll is in JPG format, which is lossy, and therefore its pixels are different? I am trying to use the checksum to detect that it is the same image: any idea how to overcome this situation? Do I need to save it as a JPG myself, then read it into memory so that I can get the same bytes that I will get from the camera roll later? If I do, I would also need to be sure that I save the same JPG format as the camera roll ...

Thanks! Patrick

A: 

I'm not an iPhone expert but I know that when saving a JPEG, there are many "quality" parameters, and if an image is encoded to JPEG format with slightly different parameters, the pixel values will be different.

So unless you can find a way to reliably convert an image to JPEG using exactly the same process as camera roll, converting the image to JPEG yourself isn't going to be of much use.

If it's possible to read the creation time of images in the camera roll, or some similar metadata, this would probably be a better method.

Artelius
I suppose I could examine JPG files created by the camera application and try to determine which parameters it uses - this puts me at risk of breaking that feature if the camera application changes the way it saves images but I can live with it.Another idea: instead of just computing the average of some image areas, I could just create a JPG for the entire image my way, regardless of what the camera application uses to create its JPG files, and just compare the checksum of MY JPG with my JPG I saved for the same image previously. Should work fine, only has an impact on performance I guess.
patrickq
A: 

The API to return you an image returns you the raw data from the camera, or an image converted to raw data from the library.

As you surmised, the JPG process is lossy, so even if the images are the same size the raw data will differ.

You would probably be better off taking an average of an area at a few fixed locations and using that as a checksum, though of course that can easily generate false positives so you need to be careful how you do it.

Kendall Helmstetter Gelner