← Back to blog

aHash: The Fastest Way to Find Duplicate Images and Videos

Sakarto's aHash (Average Hash) algorithm finds duplicate photos and videos in milliseconds by comparing brightness structure. Free, browser-based, and 100% private. Learn how to use it effectively.

Sakarto aHash duplicate finder interface showing the threshold slider and grouped duplicates

When you have a folder with 20,000 images, you don’t have time for complex math. You need raw speed. You need an algorithm that can chew through files as fast as your browser can read them from disk.

That’s exactly what aHash (Average Hash) is built for. It’s the fastest algorithm in Sakarto’s toolkit—consistently scanning thousands of images per minute while keeping your browser tab responsive. It won’t win any awards for nuance, but when your priority is speed, there’s nothing better.

Here’s how it works, what it finds, and when you should use it.


What makes aHash different from the other algorithms?

Every other algorithm in Sakarto’s image toolkit—Color Signature, pHash, wHash, dHash, BlockHash, and ORB—does something clever with the image before producing a fingerprint. Colour transforms, frequency analysis, wavelet decomposition, keypoint detection. These are powerful techniques, but they all take CPU time.

aHash does none of that. It:

  1. Shrinks the image to 16×16 pixels (256 pixels total)
  2. Converts to grayscale (discards all colour information)
  3. Computes the average brightness across all 256 pixels
  4. Compares each pixel to that average—brighter = 1, darker = 0
  5. Produces a 256‑bit binary hash

That’s it. No FFT, no colour space conversion, no matrix multiplication. Just a few hundred simple comparisons. The entire process takes under a millisecond per image on modern hardware.

The trade‑off is that aHash only captures broad brightness structure. It doesn’t care about colour, fine detail, or edges. Two images with similar brightness distributions—even if they show completely different subjects—can produce similar hashes. But for the vast majority of duplicate detection tasks—resized copies, re‑compressed versions, format conversions—aHash is more than accurate enough, and it’s orders of magnitude faster than anything else.


How the algorithm works: a deep dive

Let’s walk through exactly what happens when you scan a folder with aHash.

Step 1: Resize to 16×16 pixels

Every image—whether it’s a 50‑megapixel RAW file or a tiny 200‑pixel thumbnail—is drawn onto a 16×16 canvas. This is the secret to aHash’s speed: it doesn’t matter how big the original file is, because the fingerprint is always the same size.

Fast Mode (enabled by default for JPEGs): Instead of decoding the full image, Sakarto reads the embedded EXIF thumbnail (typically 160×120 pixels). This makes JPEG scans 5–10× faster because the browser only processes a few kilobytes instead of tens of megabytes. Since aHash downscales everything to 16×16 anyway, the thumbnail produces an identical or near‑identical hash in the vast majority of cases.

Step 2: Convert to grayscale

Each of the 256 pixels is converted to a single brightness value using the standard luminance formula: Gray = 0.299 × Red + 0.587 × Green + 0.114 × Blue

Colour information is discarded at this point. Two images with identical brightness structure but completely different colours will produce the same hash. This is a feature, not a bug—it means aHash finds copies regardless of colour shifts (like a photo and its black‑and‑white conversion).

Step 3: Compute the average brightness

Sakarto sums all 256 grayscale values and divides by 256 to get the average brightness. This number becomes the threshold for the entire image.

Step 4: Generate the 256‑bit hash

Each pixel is compared to the average:

  • Pixel > average1
  • Pixel ≤ average0

The result is a 256‑bit binary string. This is the image’s “fingerprint.” Two images with the same brightness structure will produce very similar fingerprints.

Step 5: Compare using Hamming distance

To compare two files, Sakarto XORs their 256‑bit hashes bit by bit. The number of positions where the bits differ is the Hamming distance.

  • Distance = 0 → hashes are identical
  • Distance = 10 → 10 bits differ (about 4% of the hash)
  • Distance = 50 → 50 bits differ (about 20% of the hash)

The threshold slider controls the maximum Hamming distance allowed for two files to be grouped together.

Step 6: Aspect‑ratio pre‑check

Before comparing hashes, Sakarto checks whether the two files have similar aspect ratios. If one is 4:3 and the other is 16:9—differing by more than 10%—they’re skipped entirely. This prevents a tall portrait from matching a wide landscape even if their brightness patterns coincidentally align.

Step 7: Video processing

For videos, 3 frames are extracted at 1.5‑second intervals. Each frame produces its own 256‑bit hash. The three hashes are averaged together (majority vote per bit) to produce a single representative hash for the whole file. Video scanning pauses if you switch tabs (browser limitation) and resumes when you return.


What aHash finds well

Type of duplicateHow well it worksWhy
Exact byte‑for‑byte copies✅ ExcellentThe hash will be identical.
Same photo at different resolutions✅ ExcellentResizing to 16×16 removes resolution differences entirely.
Re‑saved copies in different formats (JPEG → PNG → WebP)✅ ExcellentCompression changes individual pixels but rarely changes which pixels are above or below the average brightness.
Re‑compressed JPEGs at different quality levels✅ Very GoodQuality‑reduced JPEGs preserve the overall brightness distribution even when fine detail is lost.
Photos with minor brightness or contrast adjustments✅ GoodSmall adjustments may change a few bits, but the hash remains close enough to match at moderate thresholds.
Black‑and‑white vs. colour versions✅ GoodGrayscale conversion discards colour anyway, so the brightness structure is preserved.
Screenshots of the same image✅ Very GoodScreenshots add slight colour shifts but brightness structure is preserved.
Videos sharing similar brightness structure across key frames✅ GoodMultiple frames averaged together produce a stable fingerprint.
Heavily cropped images (over 30% removed)⚠️ May missRemoving a large portion changes the brightness distribution significantly.
Rotated or mirrored images❌ Won’t findA 90° rotation changes the position of every bright and dark pixel in the 16×16 grid. Use ORB for rotated copies.
Images with heavy colour filters or grading⚠️ May missDramatic colour shifts often change brightness distributions as well. Try pHash or Color Signature.
Night vs. day versions of the same scene❌ Won’t findBrightness reversal—day scenes have bright sky, dark ground; night scenes have dark sky, bright ground.

Understanding the Hamming threshold slider

The threshold slider is the most important control in aHash. It determines how many bit differences are allowed between two hashes before they stop being considered duplicates.

Threshold rangeWhat it doesWhen to use
0–5 (Very strict)Only near‑identical hashes match. False positives are very rare.Folders with many unrelated images where you want to avoid false positives. Finding exact copies.
10–15 (Balanced)Catches resized, re‑compressed, and reformatted copies.Default and recommended. Good starting point for most photo libraries.
20–30 (Loose)Includes more approximate brightness matches. More false positives.If you’re missing duplicates you know exist. Always compare before acting.
35+ (Very loose)Groups images with broadly similar brightness distributions.Only use for exploration or when you want to find visually related images, not just duplicates.

Tip: Start at 10. Review the results. If you’re missing duplicates you know exist, raise the threshold in increments of 2–3 until they appear. If you’re getting too many false positives, lower the threshold.


How to use aHash: step by step

Step 1: Open the tool and select a folder

Go to the aHash duplicate finder page. Click 📁 Select Folder to Scan to open a native folder picker (Chrome/Edge). Or drag and drop a folder onto the page.

Tip: Make sure Fast Mode is checked. For JPEGs, this reads the embedded thumbnail instead of the full image—5–10× faster with near‑identical accuracy.

Step 2: Wait for the scan to run

A progress bar shows how many files have been processed. Duplicate groups appear live as they’re found—you don’t need to wait for the full scan to finish before reviewing results.

Image scanning runs in a background Web Worker, so your browser tab stays responsive. Video scanning pauses when you switch tabs (browser limitation) and resumes when you return.

Step 3: Adjust the threshold

After the scan completes, use the Hamming Threshold slider (0–50) to tune matching strictness. Release the slider to re‑cluster all results instantly using the new value—no re‑scanning needed. A background Web Worker handles the re‑comparison.

Step 4: Review the duplicate groups

Results are shown in numbered groups. Each group contains files with similar brightness structures.

  • Click a card to select it (blue border)
  • Ctrl+Click (Cmd on Mac) to add to the compare list (purple border)
  • Click the 🔍 icon on hover to preview full size
  • Right‑click any card for the context menu
  • Click & drag on empty space to box‑select multiple cards

Step 5: Use the Compare modal

Ctrl+Click two or more cards, then click ⚖️ Compare in the toolbar. A modal shows each file with:

  • Full metadata (dimensions, file size, format)
  • A similarity percentage
  • Copy, Move, and Delete buttons for each file
  • A pairwise similarity matrix for 3+ files

Step 6: Take action—Move, Delete, or Copy

Select files and use the toolbar buttons. With Queue Mode on (recommended), files are staged for review first:

  • 📋 Copy — copy filename(s) to clipboard
  • 📂 Move — stage for move to a named folder
  • 🗑️ Delete — stage 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.

Step 7: Execute queued actions

Switch to the Move Queue or Delete Queue tab in the sidebar to review staged files, remove any you changed your mind about, then execute when ready.


When to use aHash vs. the other 6 algorithms

Sakarto gives you seven visual algorithms for a reason—each one handles a different type of duplication problem. Here’s when to pick aHash over the others:

Color Signature — colour accuracy

Color Signature is the only algorithm that compares actual colour. Use it when colour accuracy matters and you want to find copies that share the same palette.

Use aHash instead: Your folder is very large and speed is your primary constraint. aHash ignores colour completely, which makes it 10–100× faster.

BlockHash — absorbing JPEG compression noise

BlockHash averages brightness across 16×16 blocks, absorbing compression noise better than pixel‑level methods.

Use aHash instead: You’re scanning a mix of formats, not just heavily compressed JPEGs. aHash is faster and handles most compression levels well.

dHash (Difference Hash) — brightness and exposure-adjusted copies

dHash compares the direction of brightness change between adjacent pixels, making it robust to exposure shifts.

Use aHash instead: Your copies aren’t dramatically exposure‑adjusted. aHash is faster and works well for most brightness variations.

pHash (Perceptual Hash) — the all‑rounder for format conversions

pHash uses the Discrete Cosine Transform to extract low‑frequency structural data. It’s stable across format conversions and mild edits.

Use aHash instead: You have a folder with 20,000+ images and speed is your priority. pHash is more accurate but significantly slower.

wHash (Wavelet Hash) — speed and quality balance

wHash uses the Haar Wavelet Transform—similar quality to pHash at lower CPU cost.

Use aHash instead: You need the absolute fastest scan possible. wHash is faster than pHash but still slower than aHash.

ORB (Feature Matching) — rotation, cropping, and perspective

ORB is the only algorithm that handles rotation, cropping, and perspective warping.

Use aHash instead: Your copies are not rotated or heavily cropped. aHash is 100× faster than ORB for large folders.


Algorithm quick reference

AlgorithmBest forColour‑aware?Handles rotation?Speed
Color SignatureSame colour palette, social media re‑uploads✅ Yes❌ NoFast
aHashLarge folders, speed priority❌ No❌ NoFastest
BlockHashHeavily compressed JPEGs❌ No❌ NoVery Fast
dHashBrightness/exposure‑adjusted copies❌ No❌ NoVery Fast
pHashFormat conversions, all‑round reliability❌ No❌ NoFast
wHashSpeed + quality balance❌ No❌ NoFast
ORBRotated, cropped, perspective‑warped❌ No✅ YesSlower

Privacy: your files never leave your device

Like every Sakarto tool, the aHash duplicate finder runs entirely in your browser:

  • Zero network activity after page load. Open DevTools → Network tab and verify: no outbound requests during any scan or file operation.
  • No accounts, no cookies, no analytics. The only localStorage data is your OS detection and checkbox preferences. No file names or scan results are ever saved.
  • Folder access is scoped and session‑only. Permission expires when you close the tab.
  • Purely static—no backend. Sakarto is HTML, CSS, and JavaScript. There is no server, no database, and no API receiving your data.

Frequently asked questions (aHash specific)

“How is aHash different from the other image algorithms in Sakarto?”

aHash is the simplest and fastest of the 7 algorithms: resize to 16×16, convert to grayscale, compute the average brightness, then compare each pixel to that average. The result is a 256‑bit binary hash. It is the best starting point for large libraries where speed matters most. The trade‑off is precision—aHash only captures broad brightness structure, not fine detail. For more discriminating matching, pHash uses a Discrete Cosine Transform and is more stable across edits. dHash encodes brightness gradients and is better for exposure‑adjusted copies. Color Signature compares actual YUV colour values and is the only algorithm that detects colour differences. ORB handles rotation and perspective distortion that all hash algorithms miss entirely.

”Two clearly different photos are being grouped together. How do I fix it?”

aHash compares overall brightness structure, not visual content. Two photos with similar brightness distributions—for example, two brightly lit outdoor scenes or two dark indoor shots—can produce similar hashes even if they show completely different subjects. Fix: Lower the similarity threshold slider to 5–8, which requires hashes to be much closer before files are grouped. If false positives persist even at low thresholds, switch to pHash or Color Signature for more discriminating results. Always use the Compare modal (Ctrl+Click two cards, then Compare) to verify groups before acting.

”I know two files are duplicates but they aren’t being grouped. What’s wrong?”

Work through this checklist: first, raise the threshold slider toward 15–20. Second, check that the two files have similar aspect ratios—pairs differing by more than 10% are excluded by the aspect‑ratio pre‑check before hashing even runs. A portrait photo will never match a landscape crop of the same image regardless of threshold. Third, consider whether the duplicate has been rotated or mirrored—a 90° rotation changes the position of every bright and dark pixel in the 16×16 grid, producing a completely different hash. For rotated copies, switch to ORB.

”What does Fast Mode actually do, and when should I turn it off?”

Most JPEG files contain a small embedded thumbnail stored in their EXIF metadata, typically 160×120 or similar. Fast Mode reads this thumbnail instead of decoding the full multi‑megapixel image. For a 24 MP photo, this means processing a few KB instead of 24 MB—5–10× faster. Since aHash downscales everything to 16×16 anyway, the thumbnail produces an identical or near‑identical hash in the vast majority of cases. Turn Fast Mode off only if you notice incorrect groupings on JPEG files that you don’t see when Fast Mode is off, which would indicate your camera or editor strips EXIF thumbnails.

”How does re‑clustering the threshold work? Does it re‑scan all my files?”

No—re‑clustering is instant and requires no re‑scanning. Every file’s 256‑bit hash is stored in memory after the initial scan. When you release the threshold slider, a background Web Worker re‑runs the comparison step across all stored hashes using the new value. For a folder of 1,000 files that’s around 500,000 XOR+popcount operations, which completes in milliseconds. For 10,000 files it’s 50 million operations and may take a second or two. The scan only ever needs to run once per folder session.

”Why does video scanning pause when I switch tabs?”

Browsers throttle background video decoding to conserve battery and CPU—video elements simply stop working when the tab is hidden. The scanner detects this using the Page Visibility API and automatically pauses video processing. It resumes the moment you switch back. Image hashing is unaffected because it runs in a dedicated Web Worker: workers are not throttled by tab visibility, so images keep scanning at full speed even when you’re on a different tab.

”Can I recover files after deleting them?”

No. Sakarto uses the File System Access API’s remove() method, which permanently deletes files without sending them to the OS Recycle Bin or Trash. This is why Queue Mode is on by default: use it to stage files in the Delete Queue, preview each one using the full‑size preview icon, compare them side‑by‑side in the Compare modal, and only execute the deletion once you’re certain. Move files to a “Sakarto‑Duplicates” subfolder first if you want a recoverable intermediate step.

”What file types are supported, and why are some files silently skipped?”

Images: JPEG, PNG, GIF, WebP, BMP. Videos: MP4, WebM, MOV, MKV. Files over 40 MB are skipped to avoid browser memory pressure. HEIC/HEIF, SVG, RAW camera formats (CR2, NEF, ARW, etc.), and TIFF are not currently supported because browsers cannot natively decode them. If you need to process RAW files, convert them to JPEG or PNG first using your photo editor.

”Does this work on Firefox or Safari?”

Scanning, hash computation, result display, the Compare modal, and box‑selection all work in Firefox and Safari. The limitation is Move and Delete—those require the File System Access API, which is only available in Chrome 86+ and Edge 86+. In other browsers, run the scan, review results, use the Compare modal to decide what to keep, and use Download List to export a report. Then handle the files manually in your OS file manager.


Final thoughts

aHash is the workhorse of Sakarto’s image duplicate toolkit. It’s not the most accurate algorithm—pHash and Color Signature are both more discriminating—but it is by far the fastest. When you need to scan 50,000 images in under a minute, aHash is the only realistic choice.

It’s particularly effective for:

  • First‑pass deduplication. Run aHash on an entire drive to find obvious duplicates, then use pHash or Color Signature for a second pass on the remaining groups.
  • Large photo collections. If you have 20,000+ images and you’re not sure where to start, aHash will give you results in minutes, not hours.
  • Mixed format libraries. JPEG, PNG, WebP, BMP—aHash works equally well on all of them.

Where aHash falls short—rotated, colour‑graded, or heavily cropped copies—other Sakarto algorithms fill the gap. Use ORB for geometric transforms, pHash for format conversions and edits, or Color Signature for colour‑aware matching.

But for raw speed, nothing beats aHash. It’s the tool you reach for when your folder is too big and your time is too short.

Ready to find duplicate images and videos at lightning speed?

June 1, 2026
⏱ 17 min read
🇬🇧 English