0

I want to search for the photos by name but want to exclude exactly same copies.

Right now I am differentiating two photos by their size

if(filesize($file1) != filesize($file2)){ 
   // Files are not same
}

Above code works if $file1 and $file2 are SAME but cropped or resized version of each other. How can I decide if $file1 and $file2 are same even if they are cropped or resized

webDev
  • 135
  • 3
  • 13
  • 1
    You would need to store something in the filename, like `image1_orig`, `image1_cropped`, `image2_orig`, etc. Or store details in a file or DB that can be referenced. – AbraCadaver Sep 09 '15 at 15:08
  • I definitely wouldn't compare by size. What happens when two completely different photos coincidentally have the same size? If you're willing to research, you *may* find an answer [here](http://stackoverflow.com/q/3270929/3773066). Another option *may* be [hashing](http://stackoverflow.com/a/6822012/3773066), though that may not cover your cropped requirement. – OhBeWise Sep 09 '15 at 15:11
  • Thanks @AbraCadaver but I want to do it with previous 5lac photos present on my filesystem. – webDev Sep 09 '15 at 15:12
  • Take a look to the source of geeqie, they have the best detection of duplicated images I have seen http://geeqie.sourceforge.net/ – PerroVerd Sep 09 '15 at 15:15

1 Answers1

0

It depends on what you want to do. If you want to prevent the same photo from being shown if it has been uploaded by two different users, then you will have to use a library such as Libpuzzle to compare the two images visually and don't show the identical ones.

If you are manually creating thumbnails and cropped/resized version of an image, then you can put an identifier in the name, store them in the same folder or something like that. Exactly how you do it will depend on your current structure.

Drown
  • 5,852
  • 1
  • 30
  • 49