Crates.io | imagehash |
lib.rs | imagehash |
version | 0.3.0 |
source | src |
created_at | 2024-01-01 16:26:56.005504 |
updated_at | 2024-01-28 02:38:23.280559 |
description | image hashing library |
homepage | |
repository | https://github.com/takebayashi/imagehash-rs |
max_upload_size | |
id | 1085424 |
size | 61,132 |
The imagehash
crate provides image hashing algorithms.
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