Files

Finding images

Install dependencies with python -m pip install -r find_duplicates/requirements.txt from the repository root. The script searches directories recursively for JPG, JPEG, PNG, WebP, BMP and TIFF images.

Run these examples from the find_duplicates directory:

# List duplicates; use --delete to delete all but the highest-resolution image.
python main.py duplicates DIRECTORY [--method hash|name|stats] [--delete]
# The original invocation is also supported.
python main.py DIRECTORY [--delete]
# Find matches for one image in a directory.
python main.py search IMAGE DIRECTORY [--method hash|name|stats]

The default hash method uses perceptual hashes with a maximum distance of 3, so matches can be visually similar rather than byte-identical. name compares case-sensitive filenames including extensions; stats compares file size in bytes and image width and height. Neither guarantees identical content. Search excludes the source image itself. Duplicate groups compare each candidate to the first image in the group, not transitively to every member.

Deletion is opt-in. The keeper has the highest pixel count, with file size breaking ties. Review results without --delete first, especially when using name or stats matching.

Testing and building

From the repository root:

python -m unittest discover -s find_duplicates -p "test_*.py" -v
ruff check --select E,F,I --line-length 120 find_duplicates
cd find_duplicates
python -m PyInstaller --clean --noconfirm --onefile --name find_duplicates main.py

Install Ruff and PyInstaller separately to run linting and building. The build produces find_duplicates/dist/find_duplicates for the current OS and architecture. The Gitea workflow tests and lints changes; successful pushes to main also build the executable and install it as ~/tools/find_duplicates on the four self-hosted runners.