Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abonander/img_hash
A Rust library for calculating perceptual hash values of images
https://github.com/abonander/img_hash
Last synced: 6 days ago
JSON representation
A Rust library for calculating perceptual hash values of images
- Host: GitHub
- URL: https://github.com/abonander/img_hash
- Owner: abonander
- License: apache-2.0
- Created: 2014-11-18T20:49:53.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-03-13T10:11:47.000Z (9 months ago)
- Last Synced: 2024-11-29T15:11:45.102Z (13 days ago)
- Language: Rust
- Homepage:
- Size: 1.11 MB
- Stars: 313
- Watchers: 6
- Forks: 65
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-rust-cn - abonander/img_hash
- awesome-rust - abonander/img_hash
- awesome-rust - abonander/img_hash
- awesome-rust-cn - abonander/img_hash
- awesome-rust-zh - abonander/img_hash - 感知图像哈希,和比较相等性与相似性。 (库 / 图像处理)
README
img_hash [![Build Status](https://travis-ci.org/abonander/img_hash.svg?branch=master)](https://travis-ci.org/abonander/img_hash) [![Crates.io shield](https://img.shields.io/crates/v/img_hash.svg)](https://crates.io/crates/img_hash)
========##### 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](http://blockhash.io).
This crate can operate directly on buffers from the [PistonDevelopers/image][1] crate.
[1]: https://github.com/PistonDevelopers/image
Usage
=====
[Documentation](https://docs.rs/img_hash)Add `img_hash` to your `Cargo.toml`:
[dependencies.img_hash]
version = "3.0"
Example program:```rust
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
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)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.