• Stars
    star
    314
  • Rank 133,353 (Top 3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 10 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Rust library for calculating perceptual hash values of images

img_hash Build Status Crates.io shield

Now builds on stable Rust! (But needs nightly to bench.)

A library for getting perceptual hash values of images.

Thanks to Dr. Neal Krawetz for the outlines of the Mean (aHash), Gradient (dHash), and DCT (pHash) perceptual hash algorithms:
http://www.hackerfactor.com/blog/?/archives/432-Looks-Like-It.html (Accessed August 2014)

Also provides an implementation of the Blockhash.io algorithm.

This crate can operate directly on buffers from the PistonDevelopers/image crate.

Usage

Documentation

Add img_hash to your Cargo.toml:

[dependencies.img_hash]
version = "3.0"

Example program:

 extern crate image;
 extern crate img_hash;
 
 use img_hash::{HasherConfig, HashAlg};

 fn main() {
     let image1 = image::open("image1.png").unwrap();
     let image2 = image::open("image2.png").unwrap();
     
     let hasher = HasherConfig::new().to_hasher();

     let hash1 = hasher.hash_image(&image1);
     let hash2 = hasher.hash_image(&image2);
     
     println!("Image1 hash: {}", hash1.to_base64());
     println!("Image2 hash: {}", hash2.to_base64());
     
     println!("Hamming Distance: {}", hash1.dist(&hash2));
 }

Benchmarking

In order to build and test on Rust stable, the benchmarks have to be placed behind a feature gate. If you have Rust nightly installed and want to run benchmarks, use the following command:

cargo bench --features bench

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

More Repositories

1

multipart

A backend-agnostic extension for file uploads in HTTP libraries for Rust
Rust
190
star
2

mime_guess

MIME type guessing of file extensions for Rust.
Rust
155
star
3

anterofit

Strongly typed, asynchronous REST client framework for Rust.
Rust
134
star
4

multipart-async

Multipart requests with an asynchronous API.
Rust
72
star
5

img-dup

A tool for finding duplicate and similar images, written in Rust
Rust
55
star
6

buf_redux

A drop-in replacement for Rust's std::io::BufReader, with extra features
Rust
39
star
7

readme-doctest-poc

Automatically test Rust code examples in your README
Rust
21
star
8

const-cstr

Create static C-compatible strings from Rust string literals.
Rust
16
star
9

ferrite

Predecessor to Anterofit (https://github.com/abonander/anterofit)
Rust
13
star
10

safemem

Safe wrappers for `memmove`, `memset`, etc. in Rust
Rust
11
star
11

rawr

Reddit API Wrapper for Rust. HTTP-client-agnostic.
Rust
8
star
12

wingui

A safe Rust wrapper for the Windows GUI
Rust
7
star
13

vec-vp-tree

A vantage-pont-tree backed by a contiguous `Vec` for better data locality.
Rust
4
star
14

rust-what-now

A newbie's field guide to contributing to the Rust ecosystem.
4
star
15

fontconfig-rs

A wrapper around freedesktop's fontconfig utility, for locating fontfiles on a Linux-based system. Requires libfontconfig to be installed.
Rust
4
star
16

file_dialog

A file dialog in Rust using Conrod
Rust
3
star
17

mvp-tree-rs

A multi-vantage point (MVP) tree for Rust.
Rust
2
star
18

thread-stack

A concurrent stack datastructure for Rust which uses a thread's stack as the backing storage.
Rust
1
star
19

better_unwraps

Rust
1
star
20

dbl-buf

Generic double-buffer for Rust
Rust
1
star
21

img-hash-extern

Rust
1
star
22

async-mlock-poc

Rust
1
star
23

display_bytes

Rust
1
star
24

py-emulatorlib

A Python 3 wrapper for the telnet commands exposed by the Android emulator.
1
star