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
- Image
Multi Hash - A collection of per-segment hashes produced by
crop_resistant_hash.
Enums§
Constants§
- SNAP_
EPS - ε threshold for the snap-to-threshold tie-break used by
phash,phash_simple,whash_db4, andwhash_db4_robust. Coefficients withinSNAP_EPSof the threshold map deterministically to bit 0 across all ports. Seespec/SPEC.md§“Threshold tie-break”. - WHASH_
DB4_ ROBUST_ EPS - ε threshold for
whash_db4_robust. Coefficients with|c| < EPSsnap to 0 before median + threshold. Seespec/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_EPSto exactly zero before computing the median and threshold. Real-world photos produce the same hash aswhash_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 Pythonimagehash.whash(mode='db4')for those pathological cases. - whash_
haar