Dhash

Dhash's (or difference hashes) are a way of calculating similarity between images. If two images have a similar dhash, then the likelihood is that they both are depicting the same image (albeit slightly cropped compressed etc).

For more information, check out the links below.

Installation

gem 'dhash'

Usage

hash1 = Dhash.calculate('face-high.jpg')
hash2 = Dhash.calculate('face-low.jpg')

if Dhash.hamming(hash1, hash2) < 10
  puts "Images are very similar"
else
  puts "No match"
end