Class: Phash::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/phash/image.rb

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ Image

Returns a new instance of Image.



3
4
5
# File 'lib/phash/image.rb', line 3

def initialize(image)
  @image = image
end

Instance Method Details

#distance_from(other_image) ⇒ Object



15
16
17
# File 'lib/phash/image.rb', line 15

def distance_from(other_image)
  Phash.distance(fingerprint, other_image.fingerprint)
end

#duplicate?(other_image, threshold: 10) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/phash/image.rb', line 11

def duplicate?(other_image, threshold: 10)
  distance_from(other_image) < threshold
end

#fingerprintObject



7
8
9
# File 'lib/phash/image.rb', line 7

def fingerprint
  @fingerprint ||= Phash.fingerprint(@image)
end