3 releases (breaking)
0.3.0 | Jan 28, 2024 |
---|---|
0.2.0 | Jan 3, 2024 |
0.1.0 | Jan 1, 2024 |
#808 in Images
Used in videohash
42KB
291 lines
imagehash
The imagehash
crate provides image hashing algorithms.
Supported Algorithms
- Average Hash (aHash)
- Difference Hash (dHash)
- Perceptual Hash (pHash)
Usage
let img_filename = "tests/1.jpg";
let img = image::open(img_filename).unwrap();
// Simple usage
let hash = imagehash::average_hash(&img);
println!("{}", hash); // hex-encoded hash string
// Advanced usage
let hasher = imagehash::AverageHash::new()
.with_image_size(8, 8)
.with_hash_size(8, 8)
.with_resizer(|img, w, h| {
// Your custom resizer function
img.resize_exact(w as u32, h as u32, image::imageops::FilterType::Lanczos3)
});
let hash = hasher.hash(&img);
println!("{}", hash); // hex-encoded hash string
lib.rs
:
The imagehash
crate provides image hashing algorithms.
Supported Algorithms
- Average Hash (aHash)
- Difference Hash (dHash)
- Perceptual Hash (pHash)
Usage
let img_filename = "tests/1.jpg";
let img = image::open(img_filename).unwrap();
// Simple usage
let hash = imagehash::average_hash(&img);
println!("{}", hash); // hex-encoded hash string
// Advanced usage
let hasher = imagehash::AverageHash::new()
.with_image_size(8, 8)
.with_hash_size(8, 8)
.with_resizer(|img, w, h| {
// Your custom resizer function
img.resize_exact(w as u32, h as u32, image::imageops::FilterType::Lanczos3)
});
let hash = hasher.hash(&img);
println!("{}", hash); // hex-encoded hash string
Dependencies
~1.5MB
~28K SLoC