knjcode/imgdupes

Identifying and removing near-duplicate images using perceptual hashing.

What it solves

When you have a large collection of images, you often end up with near-duplicates: the same photo saved at slightly different resolutions, re-encoded, or subtly edited. Traditional duplicate finders like fdupes only catch exact copies. imgdupes fills that gap by detecting images that are visually alike but not byte-identical, so you can clean up your library without missing those close variants.

How it works

imgdupes computes a perceptual hash for each image — a compact fingerprint that summarises its visual content. It supports several hashing algorithms (phash, ahash, dhash, whash, and a fixed version of ImageHash's phash). For each pair of images, it measures the Hamming distance between their hashes; if that distance is below a threshold you specify (e.g., 4), the images are considered near-duplicates. The tool then lists these groups and, if you ask, lets you interactively choose which files to keep and which to delete. For very large image sets, imgdupes can use approximate nearest‑neighbour search libraries (NGT, hnsw) or exact search with faiss to speed up the comparison step.

Who it’s for

Anyone managing a large image library — photographers, archivists, or developers building image datasets — who needs to remove redundant photos without losing visually distinct ones. It’s a command‑line tool, so it suits users comfortable with terminal workflows and automated scripts.

Highlights

  • Works with multiple perceptual hash algorithms (phash, ahash, dhash, whash, phash_org)
  • Lets you set the similarity threshold via Hamming distance
  • Recursive directory scanning, file‑list input, and query‑by‑example
  • Interactive delete prompts or non‑interactive auto‑delete with --noprompt
  • Optional iTerm2 image display (--imgcat) to preview duplicates
  • Fast approximate search via NGT or hnsw, plus exact search via faiss
  • Can run via Docker without installing dependencies
  • Includes a dry‑run mode and logging for safe testing

Related

  • Project
  • Project
  • Project
  • Project