views:

66

answers:

5

I want to make sample WinForm C# app for hunting duplicate photos on my laptop.
My question is is there some record, tag ,Exif data or anything else which is unique for JPG(photo) file.
So I can read that data put into data set and hunt for duplicates.

+1  A: 

I would just compare the properties and if they all match then hash the contents and compare.

Preet Sangha
Properties of file ? Are they same even if is file copied from SD in different time intervals
adopilot
It depends on the program you use, but Windows does preserve the date times.
netadictos
+2  A: 

We could say Exif data is unique. This table gives you a good resume of what to get from Exif Data: http://en.wikipedia.org/wiki/Exchangeable_image_file_format#Example

Look at this project, sure the code will help you:

http://jpegdata.codeplex.com/

In this stackoveflow question, there is a good answer to get Exif data:

"If you're compiling against v3 of the Framework (or later), then you can load the images using the BitmapSource class, which exposes the EXIF metadata through the Metadata property"

Nevertheless, I would compare name and date, and it must be enough.

netadictos
+1  A: 

You could read in the pictures byte by byte and compare them. If they don't match stop reading.

Something like this. It's pretty vague but you'll get the idea.

while (match && !end)
{
    b1 = getnexctbytefromfilefirstfile();
    b2 = getnextbytefromfilesecondfile();

    if(b1 != b2)
    {
        match = false;
    }

    if(b1 == null || b2 == null)
    {
        end = true;
    }
}
Ash Burlaczenko
+2  A: 

Why not use the checksum for the file? create a hashtable for all the files you have scanned with the checksum as the key

Gunjan
+1  A: 

If you want to go the hashing route, take a look at this question.

Ferruccio