The duplicate finder is great when you don’t know what you’re looking for. It scans a folder and automatically groups everything similar. But what if you already know exactly which file you want copies of?
That’s where Reverse Image Search comes in. Instead of grouping everything, you upload one reference file first. Sakarto processes it immediately, then scans your chosen folder and returns only the files that look like that specific reference. The reference is pinned at the top with a protected badge—it can never be accidentally moved or deleted.
With the pHash (Perceptual Hash) algorithm, it’s the most reliable all‑round choice for finding copies of a specific reference. pHash uses the same mathematical foundation as JPEG compression—the Discrete Cosine Transform—to extract the low‑frequency “essence” of an image. It finds re‑compressed, resized, watermarked, and lightly edited copies with fewer false positives than other hash algorithms.
What makes pHash reverse search different from aHash or dHash?
All three algorithms produce a binary hash and compare using Hamming distance. But they encode fundamentally different visual properties:
| aHash | dHash | pHash | |
|---|---|---|---|
| What it encodes | Average brightness per pixel | Direction of brightness change | Low‑frequency frequency content |
| Sensitive to | Overall brightness level | Exposure, brightness shifts | Re‑compression, watermarking, mild edits |
| Best for | Speed, exact copies | Exposure‑adjusted copies | Format conversions, watermarks, precision |
The key insight: pHash uses the Discrete Cosine Transform—the same mathematics that underpins JPEG compression—to extract the image’s low‑frequency “essence.” JPEG compression works by applying a DCT and discarding small high‑frequency coefficients. Re‑compressing a JPEG barely changes the low‑frequency coefficients that pHash reads, while it does affect the pixel values that aHash or dHash read. This is why pHash is so stable across re‑compression, format conversions, and mild edits.
How reverse search works
The standard Find Duplicate Images & Videos workflow scans a folder and compares every file against every other file. That’s O(n²) complexity—fine for a few hundred images, but it gets slower as the folder grows.
Reverse Search does something much smarter. It fingerprints your reference once, then compares each folder file only against that reference. That’s O(n) complexity—linear scaling. A folder of 10,000 images takes roughly the same time per file as a folder of 100. The scan speed depends only on the number of files, not how many of them are similar to each other.
This makes reverse search the faster choice for large folders where you already know what you’re looking for.
The reference protection system
The reference file is treated differently from every other file in the scan. When you upload it, Sakarto immediately:
- Computes its fingerprint using pHash
- Shows a thumbnail preview so you can confirm the right file was loaded
- Pins it at the top of the results as soon as scanning starts
- Displays a blue REFERENCE badge on the card
- Prevents it from being moved or deleted—Move and Delete buttons are disabled on the reference card
This last point is critical. If you’re using reverse search to find copies of a file you want to keep, you don’t want to accidentally delete the original. The reference protection system makes that impossible.
How the pHash algorithm works
The pHash algorithm follows a straightforward pipeline. Here’s exactly what happens when you run a reverse search:
Step 1: Process the reference file immediately
When you upload your reference file, Sakarto processes it right away—before you even select the folder to search. The image is resized to 32×32 pixels, converted to grayscale, and a 2D Discrete Cosine Transform is applied. The top‑left 8×8 low‑frequency coefficients are extracted and thresholded against their mean to produce a 64‑bit hash. The reference card appears immediately with a blue REFERENCE badge, confirming that your file is loaded and ready.
Step 2: Resize each folder file to 32×32
For each image in the scanned folder, Sakarto draws it onto a 32×32 canvas. This normalises all images to the same size—a 12‑megapixel photo and a 200‑pixel thumbnail both become the same 32×32 grid. In Fast Mode, JPEG files use their embedded EXIF thumbnail instead of the full image, making scans 5–10× faster.
Step 3: Convert to grayscale and apply DCT
Each of the 32×32 = 1024 pixels is converted to a single brightness value using the standard luminance formula. A separable 2D Discrete Cosine Transform is applied row‑wise and column‑wise. This transforms the image from the spatial domain (pixel positions) into the frequency domain. The top‑left region contains low‑frequency (coarse structure) information; the bottom‑right contains high‑frequency (fine detail) information.
Step 4: Extract the 8×8 low‑frequency coefficients
Only the top‑left 8×8 = 64 DCT coefficients are kept. These represent the lowest spatial frequencies—the broad shapes, major contrasts, and dominant structural content. High‑frequency detail (fine textures, sharp edges, noise, watermarks, and compression artifacts) is discarded. This is what makes pHash robust to re‑compression, watermarking, and mild edits.
Step 5: Produce the 64‑bit hash
Each of the 64 DCT coefficients is compared to the mean of all coefficients (excluding the DC component at position 0, which represents overall brightness). If a coefficient is above the mean, its bit is 1; if at or below, its bit is 0. The resulting 64‑bit binary string is the pHash fingerprint.
Step 6: Compare against the reference using Hamming distance
To compare a folder file against your reference, Sakarto XORs their 64‑bit hashes bit by bit. The number of positions where the bits differ is the Hamming distance. An aspect‑ratio pre‑check first discards pairs where proportions differ by more than 10%. If the Hamming distance is at or below the threshold, the file is added to the results.
Step 7: Reference pinned first, matches rendered live
The reference card always appears at position 0 with a blue REFERENCE badge. Each matching file is rendered as a card immediately when found—you see results appear live without waiting for the full scan.
What pHash reverse search finds well
| Type of copy | How well it works | Why |
|---|---|---|
| Exact copies of your reference | ✅ Excellent | The hash will be identical. |
| Reference saved at different resolutions | ✅ Excellent | Resizing to 32×32 removes resolution differences. |
| Re‑saved copies in different formats (JPEG → PNG → WebP) | ✅ Excellent | Format conversions affect pixels but not low‑frequency DCT coefficients. |
| Re‑compressed JPEGs at different quality levels | ✅ Excellent | pHash reads the coefficients JPEG preserves most carefully. |
| Watermarked copies (logos, text overlays) | ✅ Very Good | Watermarks are high‑frequency detail; pHash ignores them. |
| Mild colour‑graded versions | ✅ Very Good | Low‑frequency luminance structure is largely preserved. |
| Lightly sharpened or noise‑reduced copies | ✅ Good | Sharpening amplifies high frequencies; pHash ignores them. |
| Screenshots of the reference image | ✅ Very Good | Screenshots preserve structural content. |
| Videos sharing key visual scenes with the reference | ✅ Good | Video frames are averaged. |
| Heavily cropped images (over 30% removed) | ⚠️ May miss | Structural content shifts too much. |
| Rotated or mirrored copies | ❌ Won’t find | DCT is not rotation‑invariant. Use ORB. |
| Dramatic colour transformations | ⚠️ May miss | Luminance structure can change significantly. Try dHash or Color Signature. |
| Stylised versions (watercolour, posterise, extreme filters) | ⚠️ May miss | Extreme filters change structural content. |
Understanding the Hamming threshold slider
The threshold slider determines how strictly a folder file must match your reference to be considered a copy. Lower values = stricter matching.
| Threshold range | What it does | When to use |
|---|---|---|
| 0–5 (Very strict) | Only near‑identical frequency patterns match. False positives are very rare. | Finding exact copies and direct re‑exports of your reference. |
| 6–15 (Balanced) | Catches resized, re‑compressed, watermarked, and lightly edited copies. | Default and recommended. The default of 10 is well‑calibrated for pHash’s 64‑bit hash space. |
| 16–25 (Loose) | Includes more approximate structural matches. More false positives. | If you’re missing duplicates with significant edits or compressions. |
| 30+ (Very loose) | Groups images with broadly similar frequency patterns. | Only use for exploration. Expect false positives. |
Tip: Because pHash is a 64‑bit hash (unlike aHash and dHash which are 256‑bit), the threshold numbers map differently. A value of 10 on pHash is stricter than 10 on aHash. Start at 8–10 and adjust from there.
How to use pHash reverse search: step by step
Step 1: Select your reference file
Click Choose Reference File in the left panel. Select any image or video from your computer. A preview appears immediately so you can confirm you picked the right file. Sakarto processes the reference file right away—computing its hash before you even select the folder. This means the search starts instantly once you pick a folder.
Tip: The reference file does not need to be inside the folder you’re about to scan. It can be from anywhere on your computer.
Step 2: Select the folder to search
Once a reference file is loaded, the Choose Folder to Search button becomes active. Click it to open a native folder picker (Chrome/Edge). Or drag and drop a folder onto the page. The folder count shows how many files were found. The Start Search button activates once both the reference file and a folder are selected.
Tip: Enable Fast Mode in the toolbar if you’re scanning many JPEG files—it reads embedded thumbnails and is 5–10× faster than loading full images.
Step 3: Start the search
Click 🔍 Start Search. The reference file card appears immediately at the top of the results with a blue REFERENCE badge. A progress bar shows how many files have been scanned. You can switch browser tabs during the search—image processing runs in a background Web Worker and continues uninterrupted. Video processing pauses when the tab is hidden and resumes when you return.
Step 4: Adjust the threshold if needed
Use the Similarity Threshold slider to tune matching sensitivity. Releasing the slider triggers an instant re-search using already-computed hashes—no re-scan needed. If expected copies are missing, raise the threshold. If too many unrelated files appear, lower it.
Step 5: Review matches as they appear
Every time a matching file is found, it appears as a new card next to the reference. The header count updates live. Once the scan finishes, a final summary shows the total number of similar files found.
- Click a card to select it (blue border)
- Ctrl+Click (Cmd+Click on Mac) to add to the compare list (purple border)
- Click the 🔍 icon on hover to preview full size with metadata
- Right‑click any card for the context menu (the reference card has Move/Delete grayed out)
- Click & drag on empty space to box‑select multiple result cards
Step 6: Compare reference vs. match side‑by‑side
Ctrl+Click the reference card and one or more match cards, then click ⚖️ Compare in the toolbar. A modal opens showing all selected files side‑by‑side with their dimensions, file size, path, and a similarity percentage. For 3+ files, a full pairwise similarity matrix is shown. Similarity percentages above 80% are shown in green, 50–80% in amber, and below 50% in red—giving you a quick visual indicator of how close each match is to your reference.
Step 7: Act on matches—Move, Delete, or Copy
Select the files you want to act on (not the reference—it’s protected) and use the toolbar. With Queue Mode on (recommended), files are staged first:
- 📋 Copy — copy filename(s) to clipboard
- 📂 Move — stage matches for move to a named folder
- 🗑️ Delete — stage matches for permanent deletion
- ⚖️ Compare — view selected files side‑by‑side
Warning: Deletions are permanent. The File System Access API bypasses the recycle bin. Always use Queue Mode to review before executing. The reference file cannot be deleted or moved.
Step 8: Queue Mode—review before you commit
When Queue Mode is enabled (the default), clicking Move or Delete stages files rather than acting immediately. Switch to the Move Queue or Delete Queue tab in the sidebar to review what’s staged, remove individual files, then execute when ready.
Reverse Search vs. Find Duplicates: which to use?
| Reverse Search | Find Duplicates | |
|---|---|---|
| What it does | Finds copies of one specific reference file | Groups all similar files in a folder |
| Complexity | O(n) — each file compared against reference | O(n²) — all files compared against each other |
| Speed | Faster for large folders | Slower for large folders |
| Reference protection | Yes — reference pinned and cannot be deleted | No — all files are treated equally |
| Best for | You know exactly which file you’re looking for | You want to see every duplicate group in a folder |
| When to use | ”I need to find every copy of this specific photo" | "I need to clean up my entire photo library” |
Recommendation: Use both. Run Find Duplicates to see the big picture. Then use Reverse Search for specific important files to clean up their copies without risking the originals.
When to use pHash vs. the other 6 algorithms for reverse search
Sakarto gives you seven visual algorithms for a reason—each one handles a different type of duplication problem. Here’s when to pick pHash over the others:
Color Signature — colour accuracy
Color Signature is the only algorithm that compares actual colour.
Use pHash instead: Your reference’s copies have been lightly edited, re‑compressed, or watermarked in ways that preserve colour but change pixel values. pHash is colour‑blind and stable across these edits—Color Signature would see the colour changes as mismatches.
aHash (Average Hash) — speed above all else
aHash is the fastest algorithm—it reads individual pixels and compares them to the overall mean.
Use pHash instead: You need better accuracy than aHash. pHash finds re‑compressed, watermarked, and lightly edited copies that aHash misses. The speed difference is usually acceptable for most collections.
BlockHash — noise tolerance
BlockHash averages brightness over blocks, making it tolerant of compression noise.
Use pHash instead: You want fewer false positives. BlockHash is a coarse descriptor and can over‑match; pHash’s frequency‑domain encoding is more discriminating.
dHash (Difference Hash) — brightness and exposure-adjusted copies
dHash encodes gradient directions and handles exposure shifts well.
Use pHash instead: Your reference’s copies have been edited in ways beyond just brightness changes—watermarking, re‑compression, format conversions. pHash is more broadly stable across a wider range of edits.
wHash (Wavelet Hash) — speed and quality balance
wHash uses the Haar Wavelet Transform—similar quality to pHash at lower CPU cost.
Use pHash instead: You want the most stable hash for a mixed collection. pHash’s DCT basis is the same as JPEG compression, making it uniquely robust to the most common image edits.
ORB (Feature Matching) — rotation, cropping, and perspective
ORB is the only algorithm that handles rotation, cropping, and perspective warping.
Use pHash instead: Your reference’s copies are not rotated or heavily cropped. pHash is 100× faster than ORB and handles a wider range of edits that don’t involve geometric transformations.
pHash — the all‑round specialist
pHash is the most reliable general‑purpose algorithm for reverse search. Use it when you need to find re‑compressed, resized, watermarked, or lightly edited copies of your reference with minimal false positives.
Use pHash when: You have a mixed collection of images from different sources and you want the widest possible coverage of copy types without too many false positives. When in doubt, pHash is the safest starting point.
Algorithm quick reference for reverse search
| Algorithm | Best for | Colour‑aware? | Handles rotation? | Handles re‑compression? | Handles watermarks? | Speed |
|---|---|---|---|---|---|---|
| Color Signature | Same colour palette, social media re‑uploads | ✅ Yes | ❌ No | ⚠️ Moderate | ⚠️ Moderate | Fast |
| aHash | Large folders, speed priority | ❌ No | ❌ No | ⚠️ Moderate | ⚠️ Moderate | Fastest |
| BlockHash | Heavily compressed JPEGs, noisy images | ❌ No | ❌ No | ✅ Good | ⚠️ Moderate | Very Fast |
| dHash | Brightness/exposure‑adjusted copies | ❌ No | ❌ No | ⚠️ Moderate | ❌ No | Very Fast |
| pHash | Format conversions, re‑compression, watermarks | ❌ No | ❌ No | ✅ Excellent | ✅ Excellent | Fast |
| wHash | Speed + quality balance | ❌ No | ❌ No | ✅ Good | ✅ Good | Fast |
| ORB | Rotated, cropped, perspective‑warped | ❌ No | ✅ Yes | ✅ Good | ✅ Good | Slower |
Privacy: your files never leave your device
Like every Sakarto tool, the reverse image search runs entirely in your browser:
- Zero network activity after page load. Open DevTools → Network tab and verify: no outbound requests during any search, compare, or file operation. Your reference file and folder contents are never transmitted anywhere.
- No accounts, no cookies, no analytics. The only localStorage data is your OS detection and checkbox preferences. No file names, paths, or scan results are ever saved.
- Folder access is scoped and session‑only. Permission is granted only for the specific folder you select, lasts only while the tab is open, and is revocable at any time from browser site settings.
- Purely static—no backend. Sakarto is HTML, CSS, and JavaScript. There is no server, no database, and no API receiving any data from you.
Frequently asked questions (pHash reverse search specific)
“Why is pHash the recommended all‑round choice for reverse image search?”
pHash encodes the dominant low‑frequency content of an image using a Discrete Cosine Transform—the same mathematical operation JPEG compression uses internally. Low‑frequency DCT coefficients represent the structural “essence” of the image (broad shapes, overall luminance distribution, dominant lines) and are extremely stable across edits. Re‑compression, format conversion (JPEG→PNG→WebP), mild colour grading, sharpening, light watermarks, and slight resizing all affect high‑frequency detail while leaving the low‑frequency structure almost unchanged. aHash is faster but more sensitive to compression noise. dHash is better specifically for exposure‑adjusted copies. ORB handles rotation but is much slower. pHash hits the best balance of stability, precision, and speed for the widest range of typical photo duplicates.
”Does my reference file need to be inside the folder I’m scanning?”
No—select it from anywhere on your computer. Sakarto skips the reference automatically if it appears inside the scanned folder, matched by filename, file size, and last‑modified timestamp. The reference is always pinned at position 0 and protected from deletion regardless.
”A copy of my reference isn’t appearing in results. What should I try?”
First, raise the threshold toward 15–18. Second, check aspect ratios—pairs differing by more than 10% are excluded by the pre‑check before hashing runs. Third, consider the type of edit: pHash handles re‑compression, format conversion, mild colour grading, and light watermarks well. It does not handle rotation (try ORB), heavy cropping that removes more than ~30% of the image (structural content shifts too much), or very extreme brightness changes that clip large areas to white or black (try dHash for brightness‑adjusted copies). Fourth, confirm the copy decodes successfully—a corrupted or unsupported format produces a garbage hash.
”Can pHash find a watermarked version of my reference photo?”
Usually yes—watermarks are high‑frequency content (text and logos have sharp edges and fine detail). pHash uses only low‑frequency DCT coefficients and essentially ignores high‑frequency content entirely. A logo overlay in the corner, a semi‑transparent text watermark across the image, or a copyright notice along the edge will typically produce zero or very few bit differences in the pHash compared to the unwatermarked original, so the match will appear even at strict thresholds. Very large watermarks that cover a significant fraction of the image (more than ~40%) can shift enough low‑frequency content to start affecting the hash—in that case, try a slightly looser threshold.
”How does pHash handle JPEG re‑compression better than aHash?”
JPEG compression works by applying a DCT to the image and discarding small high‑frequency coefficients during encoding. Each time a JPEG is re‑saved, the encoder reconstructs pixel values from the stored (partially discarded) DCT data, meaning individual pixel values change slightly with each re‑save. aHash reads individual pixel values, so these small changes can flip bits and cause mismatches. pHash directly computes the DCT and reads the low‑frequency coefficients—the same values JPEG preserves most faithfully. Re‑saving a JPEG multiple times barely changes pHash’s input data, making it much more stable for re‑compressed copies than aHash.
”How do I decide which file to keep when comparing a reference to a match?”
Ctrl+Click the reference and the match card, then click Compare. The modal shows both files side by side with dimensions, file size, format, and a pHash similarity percentage. Values above 90% typically mean the images are perceptually near‑identical. Values of 80–90% may indicate visible but minor differences worth inspecting. As a rule: keep the largest file size (more data = better quality), or the highest resolution if sizes are similar. If one is lossless (PNG, TIFF) and the other is JPEG, the lossless version is worth keeping. For watermarked vs. unwatermarked copies, keep the unwatermarked version if quality is otherwise equal.
”Why does video scanning pause when I switch tabs?”
Browsers throttle video element processing when a tab is hidden. Sakarto detects this and pauses video frame extraction, resuming when you return. Image hashing runs in a background Web Worker unaffected by tab visibility—images keep scanning at full speed regardless of which tab is active.
”Can I recover files after deleting them?”
No. The File System Access API’s remove() method permanently deletes files without going through the OS Recycle Bin. The reference file is always protected. For matched files, use Queue Mode: stage, preview each one with the full‑size preview icon, compare against the reference in the Compare modal, then execute only when certain.
”Does this work on Firefox or Safari?”
Reference processing, folder scanning, DCT computation, result display, and the Compare modal all work in Firefox and Safari. Move and Delete require the File System Access API (Chrome 86+ and Edge 86+ only). In other browsers, complete the search and use Download List to export a report for manual file management.
Final thoughts
pHash reverse search is the tool you reach for when you need the most reliable all‑round performance. It’s the most stable hash algorithm in Sakarto’s toolkit, built on the same mathematical foundation as JPEG compression itself. It reliably finds re‑compressed, resized, watermarked, and lightly edited copies of your reference with fewer false positives than other algorithms.
It’s particularly effective for:
- Mixed‑format libraries. JPEG, PNG, WebP, BMP—pHash finds copies regardless of format.
- Re‑compressed photo collections. Images that have been saved multiple times at different quality settings.
- Watermarked image sets. Same image with and without a logo or text overlay.
- Photo archives with mild colour grading. Slight colour shifts don’t affect low‑frequency DCT coefficients.
- General‑purpose reference searches. When you don’t know what kind of copies to expect, pHash is the safest starting point.
Where pHash falls short—rotated, heavily cropped, or dramatically colour‑shifted copies—other Sakarto algorithms fill the gap. Use ORB for geometric transforms, dHash for brightness shifts, or Color Signature for colour‑aware matching.
But for the vast majority of photo collections, pHash is the best all‑round choice. It’s the algorithm that finds the copies the others miss—without the false positives that coarser methods produce.
Ready to find every copy of your reference image or video with pHash?
- Open pHash Reverse Search — free, browser‑based, no install
- Try Find Duplicates with pHash — auto‑group all similar files without a reference
- Explore All 7 Reverse Image & Video Algorithms — compare with Color Signature, aHash, BlockHash, dHash, wHash, and ORB
