Skip to main content

Image Duplicates Detective (imgduptective)

Find near-duplicate and exact-duplicate images in your photo collections using perceptual hashing.

How it works

imgduptective uses a gradient-based horizontal difference hash (dhash) to create a perceptual fingerprint of each image. Images that look similar will have similar hashes, even if the files differ in format, resolution, or compression. A hamming distance threshold controls how similar two images must be to count as duplicates.

Results are cached in a local SQLite database (~/.config/imgduptective/) so subsequent runs are fast — only new or modified files are processed.

Installation

pip install .

Or for development:

pip install -e .

Requires Python 3.10+ and Pillow.

Usage

# Find near-duplicates with hamming distance threshold of 5
imgduptective 5

# Find exact duplicates only (identical file content)
imgduptective --exact

# Add files to the database without comparing
imgduptective --add

# Check what duplicates would be found if current directory were added
imgduptective --check 5

# Show per-directory statistics
imgduptective --stats 5

# Open the built-in viewer to inspect and delete duplicates
imgduptective --view 5

Options

Flag Description
threshold Maximum hamming distance to consider a match (0 = identical perceptual hash)
--view Open the tkinter viewer to browse and manage duplicate groups
--stats Show per-directory duplicate statistics
--check Preview what duplicates would be found without modifying the database
--add Scan and hash files into the database without comparing
--photos Only process common photo formats (jpg, png, heic, webp, tiff, bmp, gif)
--exact Find exact file matches (same content) instead of perceptually similar
--no-scan Skip file scanning/hashing entirely, use the database cache only
--full-hash Use full-file SHA-1 instead of the default fast 64KB partial hash
--project NAME Use a named project database (e.g., work, personal, holidays)
--list-projects List available project databases with file counts

Projects

Organize separate photo collections into named projects. Each project has its own database:

# Scan work photos
cd ~/Photos/Work
imgduptective --project work --add

# Scan holiday photos
cd ~/Photos/Holidays
imgduptective --project holidays --add

# Find duplicates within holidays
imgduptective --project holidays 5

# List all projects
imgduptective --list-projects

Without --project, the default database is used.

Performance

The tool uses several strategies to minimize scan time:

  • Partial hashing (default): Only the first 64KB of each file is hashed (plus file size) for change detection. This is sufficient to distinguish different images while being 10-100x faster than full-file hashing on large files.
  • Stat-based caching: On repeat scans, files whose size and modification time haven't changed skip hashing entirely (a single stat() call per file).
  • --no-scan: For re-running comparisons with different thresholds without any file I/O.
  • --full-hash: Forces full SHA-1 of entire file contents when exact integrity verification is needed.
  • Multiprocessing: File hashing, image hash computation, and pair comparison all run in parallel.

Viewer

The built-in tkinter viewer (--view) displays duplicate groups side by side:

  • ←/→ or n/p/space: Navigate between groups
  • Click: Select/deselect images for deletion
  • d or Delete: Compress selected files with gzip and remove originals
  • q or Escape: Quit

Database

Hashes are stored in ~/.config/imgduptective/:

  • imgduptective.db — default project
  • imgduptective-{name}.db — named projects

The database has two tables:

  • HashValueTable: Content-addressed cache mapping file hashes to image perceptual hashes
  • FileTable: Maps file paths to their file hash, image hash, size, and modification time

Files that no longer exist are automatically pruned from the database on each scan.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imgduptective-0.3.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imgduptective-0.3.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file imgduptective-0.3.0.tar.gz.

File metadata

  • Download URL: imgduptective-0.3.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for imgduptective-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e47ee64ff5a019fdbb57cfb49dc9ba9a48fb93cf5ce6485a8a334bb2e3fa3cd0
MD5 50821a5ffd21624ebfea20e7dd07507b
BLAKE2b-256 e9875917b87f579076a07b6082e32ecd87ac1bd2e6cfe2f8b6261adb1d608518

See more details on using hashes here.

File details

Details for the file imgduptective-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: imgduptective-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for imgduptective-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 788022267c9887db755998cfe92f7b0f07ce075b875a2662e5292a01569ddd5f
MD5 9b6ff06d8137d78c2e42d5979aa7d088
BLAKE2b-256 30ec929c9815c97b9af52fee212dc6ce961fae2a5fecb8390f0dd9f325a2b45e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page