Im using the rmagick
image rmagick
for ruby ββto compare two images to detect if they are actually the same image (avoid duplication).
As usual, I do this using the difference method:
require 'rmagick' img1.difference(img2)
The above example is the output of two images, which are certainly the same. This worked very well for me until I came across a new scenario that this method does not work very well - if the images are the same (even the same size), but one of them was cropped, for example. 10px border. Now all of a sudden, although both images look exactly like the human eye, the computer will think that they are very different, because one of the images was cropped just a little.
In any case, I can handle this situation, so I still find that this is the same image, although one of them is cropped a bit?
source share