Crate img_hash [−] [src]
A crate that provides several perceptual hashing algorithms for images. Supports images opened with the image crate from Piston.
Example
Hash two images, then compute their percentage difference.
extern crate image; extern crate img_hash; use img_hash::{ImageHash, HashType}; fn main() { let image1 = image::open(&Path::new("image1.png")).unwrap(); let image2 = image::open(&Path::new("image2.png")).unwrap(); // These two lines produce hashes with 64 bits (8 ** 2), // using the Gradient hash, a good middle ground between // the performance of Mean and the accuracy of DCT. let hash1 = ImageHash::hash(&image1, 8, HashType::Gradient); let hash2 = ImageHash::hash(&image2, 8, HashType::Gradient); println!("Image1 hash: {}", hash1.to_base64()); println!("Image2 hash: {}", hash2.to_base64()); println!("% Difference: {}", hash1.dist_ratio(&hash2)); }
Structs
DCT2DFunc |
A 2-dimensional Discrete Cosine Transform function that receives and returns 1-dimensional packed data. |
ImageHash |
A struct representing an image processed by a perceptual hash. For efficiency, does not retain a copy of the image data after hashing. |
Enums
HashType |
An enum describing the hash algorithms that |
Traits
HashImage |
A trait for describing an image that can be successfully hashed. |
Type Definitions
LumaBytes |
A byte vector representing an 8-bit grayscale image. |
Rowstride |