Glossary · Perceptual hash
What is a perceptual hash? How apps spot similar images
Short answer
A perceptual hash is a short fingerprint that describes how an image looks rather than its exact bytes. Similar pictures, such as a photo and its resized copy, produce hashes that differ in only a few bits. Duplicate finders compare these hashes to spot near-copies that a normal file hash would treat as completely different.
Last updated
How does a perceptual hash work?
The common average-hash and difference-hash methods follow the same pattern:
- Shrink the image to a tiny grid, often 8x8 or 9x8 pixels, which removes size and fine detail.
- Convert it to greyscale so colour shifts do not matter.
- Compare each pixel with the average (aHash) or with its neighbour (dHash).
- Write a 1 or a 0 for each comparison, giving a 64-bit fingerprint.
pHash adds a discrete cosine transform before the comparison, which makes it steadier under compression and small brightness changes. Two images are compared by counting how many of the 64 bits differ, the Hamming distance. A distance of a handful of bits usually means the same picture.
Because the fingerprint is tiny, comparing thousands of photos is fast: a phone can check every pair in a large library in seconds without opening the full images again.
How is it different from a file hash?
A cryptographic file hash is designed so that changing one byte changes the whole hash, the avalanche effect. That is perfect for proving two files are identical and useless for asking whether they look alike. Perceptual hashing deliberately does the opposite: it is locality-sensitive, so close inputs give close outputs.
| Change to the photo | File hash | Perceptual hash |
|---|---|---|
| None (exact copy) | Same | Same |
| Resized or re-compressed | Completely different | Same or very close |
| Slight brightness edit | Completely different | Close |
| Heavy crop or rotation | Completely different | Often far apart |
Where do perceptual hashes fall short?
Basic hashes struggle with crops, rotations, mirrored images and overlays, and they can mark unrelated pictures with similar layouts as matches, such as two plain sky shots. Research also shows hashes can be fooled on purpose with tiny pixel changes. Large-scale systems such as Microsoft's PhotoDNA use more robust designs for those reasons.
Modern photo cleaners often go further, using image embeddings from a neural network to compare content, plus capture time to keep separate moments apart. That is how a tool can group burst frames while leaving last year's shot of the same view alone. See near-duplicate photo for what these groups look like in practice.
Colour is also invisible to the basic methods. Two photos with the same layout but different colours, such as a red and a blue car parked in the same spot, can hash almost alike, which is why tools confirm matches with a second check.
Frequently asked questions
Can a perceptual hash find exact duplicates too?
Yes, identical images get identical hashes, but a file hash is faster and certain. Many tools run a file hash first, then a perceptual check on the rest.
What Hamming distance counts as a match?
There is no fixed rule. For 64-bit dHash, tools often treat 0 to 5 differing bits as the same image and tune from there.
Does a perceptual hash reveal what is in the photo?
No. It is a short pattern of bits about brightness layout and cannot be turned back into the picture.
Sources
- Wikipedia: Perceptual hashing (checked 31 October 2026)
Related
More in Photo cleanup terms
GalleryJury is coming soon to Android
It keeps the best shot from every burst and clears the clutter around it. 50 free photos to try, then $5 for 5,000 photos or $15 for 20,000. Pay once, nothing renews. No subscription.