fast-dhash

Crates.iofast-dhash
lib.rsfast-dhash
version1.1.0
created_at2023-03-29 20:34:45.130227+00
updated_at2025-01-20 22:42:22.814778+00
descriptionA fast rust implementation of the perceptual hash dhash
homepage
repositoryhttps://github.com/9elt/fast-dhash
max_upload_size
id824374
size1,167,245
Lorenzo Cicuttin (9elt)

documentation

README

Fast Dhash

A fast rust implementation of the perceptual hash dhash.

The main difference with other rust implementations, and the reason it is called fast, is that it uses multithreading and does not resize nor converts the image, effectively cycling through its bytes only once.

Usage

For forward and backward compatibility, fast dhash does NOT directly rely on the image crate, it is up to the user to provide the image bytes and dimensions.

use fast_dhash::Dhash;
use image::ImageReader;

let image = ImageReader::open(".test/radial.jpg")
    .expect("cannot read image")
    .decode()
    .expect("cannot decode image");

let hash = Dhash::new(
    image.as_bytes(),
    image.width(),
    image.height(),
    image.color().channel_count(),
);

println!("hash: {}", hash);
// hash: f0f0e8cccce8f0f0
Commit count: 11

cargo fmt