开发者

Is there something uniquely for JPG files so I can consiredier duplicates

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.


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.


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


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


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;
    }
}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜