Closed ksesong closed 4 years ago
I'm actually working on an API/implementation overhaul on the 3-alpha
branch. Can you try that and let me know if it's still the same issue or if it's fixed? If the latter, I'll consider this closed when I go to merge that.
So I've been trying the 3-alpha
branch version, but I can't manage to get a non-empty hash:
extern crate image;
extern crate img_hash;
use img_hash::{HasherConfig, HashAlg};
use image::GenericImageView;
fn main() {
let img = image::open("00002701.jpg").unwrap();
println!("{:?}", img.dimensions()); // Returns (643, 488)
let hasher_config = HasherConfig::new().hash_alg(HashAlg::Mean).hash_size(8, 8);
println!("{:?}", hasher_config); // Returns HasherConfig { width: 8, height: 8, hash_alg: Mean, resize_filter: "Lanczos3", gauss_sigmas: None, use_dct: false }
let hasher = hasher_config.to_hasher();
let hash = hasher.hash_image(&img);
println!("{:?}", hash.to_base64()); // Returns ""
}
Do you see anything wrong in my code?
Sorry, that was a bug. I added a regression test. Run cargo update
and try again.
I did some more testing with the 3-alpha
branch and it's fixed. Thanks for the library!
Closed with 3.0.
I've been testing this library with this simple script, but I can't figure out why the produced hash has an invalid size (here 56 instead of 64 bits). The size is also incorrect for
DoubleGradient
with 135 instead of 128 bits. When using theMean
,Block
orDCT
hashtype, the resulting hash has the correct length (64 bits). (I'm a novice in Rust, so I might have done something wrong.)(The image is just a random picture, I am only looking at the hash size here.)