img_hash 0.5.0

A simple library that provides perceptual hashing and difference calculation for images.
docs.rs failed to build img_hash-0.5.0
Please check build logs and if you believe this is docs.rs' fault, report into this issue report.

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));
}