Skip to main content

Crate rosetta_squint_hash

Crate rosetta_squint_hash 

Source
Expand description

rosetta-squint-hash — Byte-exact Rust port of Python imagehash 4.3.2.

Public API: Hash, ImageMultiHash, ImageHashError, hex_to_hash, hex_to_flathash, hex_to_multihash, and the algorithm functions.

Structs§

Hash
ImageMultiHash
A collection of per-segment hashes produced by crop_resistant_hash.

Enums§

ImageHashError

Constants§

SNAP_EPS
ε threshold for the snap-to-threshold tie-break used by phash, phash_simple, whash_db4, and whash_db4_robust. Coefficients within SNAP_EPS of the threshold map deterministically to bit 0 across all ports. See spec/SPEC.md §“Threshold tie-break”.
WHASH_DB4_ROBUST_EPS
ε threshold for whash_db4_robust. Coefficients with |c| < EPS snap to 0 before median + threshold. See spec/SPEC.md §whash_db4_robust.

Functions§

average_hash
colorhash
colorhash_bin_encode
SPEC.md §8 quirky bin encoding. Worked: v=4 → [0,1,1,0] (0x6), v=8 → [1,1,0,0] (0xc).
crop_resistant_hash
Compute a crop-resistant hash of an image.
dhash
dhash_vertical
hex_to_flathash
hex_to_hash
hex_to_multihash
Parse a comma-separated multi-hash hex string into an ImageMultiHash.
phash
phash_simple
phash_simple_with_factor
phash_with_factor
whash_db4
whash with mode=‘db4’ (Daubechies-4, 8-tap wavelet), remove_max_haar_ll=True.
whash_db4_robust
Cross-port-stable variant of whash_db4. Identical pipeline up to the LL band, then snaps coefficients with |c| < WHASH_DB4_ROBUST_EPS to exactly zero before computing the median and threshold. Real-world photos produce the same hash as whash_db4; pathological symmetric inputs produce a deterministic hash across every port instead of relying on PyWavelets’ C+SIMD/FMA accumulation sign. NOT byte-exact-compatible with Python imagehash.whash(mode='db4') for those pathological cases.
whash_haar