A dark cover reading '1,024 pixels. 64 bits.' above a card showing a brighter copy at hamming distance 4 and an unrelated image at distance 30

Perceptual hash from scratch: 32x32 pixels, one DCT, 64 bits, in Swift

Take a photo, resize it by 1 percent, and save it again. A byte hash such as SHA-256 of the two files has nothing in common. That is by design: change one bit of input and about half the output bits flip. It is the right property for checksums and the wrong one for finding near-duplicate photos. A perceptual hash wants the opposite property. Similar images should give similar hashes, so that “how different are these two images” becomes “how many bits differ between two 64-bit numbers”. ...

November 9, 2026 · 6 min · widnyana