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.
views:
66answers:
5I would just compare the properties and if they all match then hash the contents and compare.
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:
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.
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;
}
}
Why not use the checksum for the file? create a hashtable for all the files you have scanned with the checksum as the key
If you want to go the hashing route, take a look at this question.