3个版本 (破坏性更新)
0.3.0 | 2024年1月28日 |
---|---|
0.2.0 | 2024年1月3日 |
0.1.0 | 2024年1月1日 |
#529 in 图像
42KB
291 行
imagehash
imagehash
crate提供图像哈希算法。
支持的算法
- 平均哈希(aHash)
- 差异哈希(dHash)
- 感知哈希(pHash)
用法
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
:
imagehash
crate提供图像哈希算法。
支持的算法
- 平均哈希(aHash)
- 差异哈希(dHash)
- 感知哈希(pHash)
用法
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
依赖项
~9.5MB
~26K SLoC