https://github.com/9elt/fast-dhash
A fast rust implementation of the perceptual hash dhash
https://github.com/9elt/fast-dhash
dhash perceptual-hashing
Last synced: 4 months ago
JSON representation
A fast rust implementation of the perceptual hash dhash
- Host: GitHub
- URL: https://github.com/9elt/fast-dhash
- Owner: 9elt
- License: mit
- Created: 2023-03-29T20:22:59.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-20T22:42:14.000Z (over 1 year ago)
- Last Synced: 2026-01-01T11:56:42.518Z (5 months ago)
- Topics: dhash, perceptual-hashing
- Language: Rust
- Homepage:
- Size: 1000 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fast Dhash
A fast rust implementation of the perceptual hash [*dhash*](https://www.hackerfactor.com/blog/index.php?/archives/529-Kind-of-Like-That.html).
The main difference with other rust implementations, and the reason it is called *fast*, is that it uses multithreading and does not resize nor converts the image, effectively cycling through its bytes only once.
## Usage
For forward and backward compatibility, *fast dhash* does NOT directly rely on the [*image*](https://docs.rs/image/latest/image/index.html) crate, it is up to the user to provide the image bytes and dimensions.
```rust
use fast_dhash::Dhash;
use image::ImageReader;
let image = ImageReader::open(".test/radial.jpg")
.expect("cannot read image")
.decode()
.expect("cannot decode image");
let hash = Dhash::new(
image.as_bytes(),
image.width(),
image.height(),
image.color().channel_count(),
);
println!("hash: {}", hash);
// hash: f0f0e8cccce8f0f0
```