# 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("image1.png").unwrap(); let image2 = image::open("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

FromBase64Error |
Errors that can occur when decoding a base64 encoded string |

HashType |
An enum describing the hash algorithms that |

## Traits

HashImage |
A trait for describing an image that can be successfully hashed. |

## Functions

precompute_dct_matrix |
Precompute the DCT matrix for a given hash size and memoize it in thread-local storage. |

## Type Definitions

Rowstride |
The length of a row in a 2D matrix when packed into a 1D array. |