Project

blockhash

0.0
Low commit activity in last 3 years
No release in over a year
This is a perceptual image hash calculation and comparison tool based on the blockhash method. This can be used to match compressed or resized images to each other.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 4.2.5
 Project Readme

Blockhash

This is Ruby Gem that can be used to produce and compare perceptual image hashes.

This Gem is a translation of the algorithm at http://blockhash.io

Installation

Prerequisites

On Debian/Ubuntu/Mint you can run:

sudo apt get install libmagickwand-dev

On Arch you can run:

pacman -Syy pkg-config imagemagick

On macOS, you can run:

brew install pkg-config imagemagick

Gem Install

Install via Bundler

bundle add blockhash

Or install via RubyGems:

gem install blockhash

Usage

require "blockhash"
require "rmagick"

image1 = Magick::Image.read("image1.png").first
image2 = Magick::Image.read("image2.png").first

# Generate full image hashes
hash1 = Blockhash.calculate(image1, bits = 16)
hash2 = Blockhash.calculate(image2, bits = 16)

# Generate fast image hashes
hash1 = Blockhash.calculate_fast(image1, bits = 16)
hash2 = Blockhash.calculate_fast(image2, bits = 16)

# Generate image hash from file path
hash1 = Blockhash.calculate_from_path("image1.png", bits = 16)

# Determine if hashes are similar
similar = Blockhash.similar?(hash1, hash2, threshold = 10)

# Calculate distance between two hashes
distance = Blockhash.distance(hash1, hash2)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/actuallydamo/blockhash-ruby.