2

So guys that's what i have.

I have a 1 folder with around 30k pictures (a old backup from long time ago) and second folder used as the current backup.

so I just wanted to check if in the first folder I got pictures that I don't have in the second folder.. and if i got picture in folder 1 that I already have in folder 2 so it will be deleted from folder 1.

I thought maybe I should compare between the size on disk of 1 picture from folder 1 against all the pictures in folder 2. (with 2 for loops)

but I saw that I have 2 different pictures with the exact size (size on disk). so I can't really use it.

anyone got idea how should i do it? (remember that i got around 30k photos in folder 1 so the algorithm should be efficient)ץ

got diffrent hash for same picture. :

            using (var md5 = MD5.Create())
        {
            using (var stream = File.OpenRead("C:/Users/Sam/Desktop/1.jpg"))
            {
                Console.WriteLine(BitConverter.ToString(md5.ComputeHash(stream)));
            }
           using (var stream2 = File.OpenRead("C:/Users/Sam/Desktop/2.jpg"))
            {
                Console.WriteLine(BitConverter.ToString(md5.ComputeHash(stream2)));
            }
        }

Hi i did use this algoritem : Algorithm to compare two images in C#

but it's take too slow. (takes about 2-3 sec to compare 1 image to 100 others so its gonna be forever to compare all the images (around 30k) )..

Community
  • 1
  • 1
ShmuelCohen
  • 472
  • 3
  • 9
  • 17
  • Hi. thanks for help.. maybe can u explain me more about exeif-thumbnail ? Im still kindaof new to c# i could download a program that will do it by herself by i wanted to understand how it can be done. – ShmuelCohen Dec 16 '16 at 13:23
  • Possible duplicate of [Compare two images, and return the rate of similarity in %](http://stackoverflow.com/questions/6608315/compare-two-images-and-return-the-rate-of-similarity-in) – Maksim Simkin Dec 16 '16 at 13:41
  • One approach http://stackoverflow.com/questions/35151067/algorithm-to-compare-two-images-in-c-sharp – fubo Dec 16 '16 at 13:43

2 Answers2

2

calculate a hash from each picture and use the hash value to compare the folders

user7291698
  • 1,972
  • 2
  • 15
  • 30
  • for the same picture I got different Hash.. i edit the post to show what i tried – ShmuelCohen Dec 16 '16 at 13:21
  • are they really the same pictures or do they maybe have a different resolution or a different format? if they are exactly the same, the hash value also must be the same.. – user7291698 Dec 16 '16 at 13:26
  • Well that's a picture that the size on disk is exactly the same. and the picture herself is really the same (I took her just 1 time like 5 years ago..) i don't really know how but the size is different (only size on disk is the same). maybe something else that u can think of? – ShmuelCohen Dec 16 '16 at 13:28
  • do the pictures contain metadata? maybe in one picture the metadata was changed? – user7291698 Dec 16 '16 at 13:29
  • i think maybe that's what happened too. how can i solve it? – ShmuelCohen Dec 16 '16 at 13:32
  • maybe you can omit the metadata part of the image for the hash calculation. of course this means that you have to know where the metadata is stored (beginning of the file or end of the file). if you don't have many different image formats, this could work.. – user7291698 Dec 16 '16 at 13:38
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/130793/discussion-between-shmulikcohen-and-user7291698). – ShmuelCohen Dec 16 '16 at 13:43
0

Here's a couple of open source C# projects that do image comparison.

https://github.com/xnafan/Simple-image-comparison

https://github.com/ukushu/ImgComparator

TripleAntigen
  • 2,221
  • 1
  • 31
  • 44