Class: Phash::Image
- Inherits:
-
Object
- Object
- Phash::Image
- Defined in:
- lib/phash/image.rb
Instance Method Summary collapse
- #distance_from(other_image) ⇒ Object
- #duplicate?(other_image, threshold: 10) ⇒ Boolean
- #fingerprint ⇒ Object
-
#initialize(image) ⇒ Image
constructor
A new instance of Image.
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
11 12 13 |
# File 'lib/phash/image.rb', line 11 def duplicate?(other_image, threshold: 10) distance_from(other_image) < threshold end |
#fingerprint ⇒ Object
7 8 9 |
# File 'lib/phash/image.rb', line 7 def fingerprint @fingerprint ||= Phash.fingerprint(@image) end |