Skip to main content

Duplicate Image Finder (difPy)

Tired of going through all images in a folder and comparing them manually to check if they are duplicates?

The Duplicate Image Finder (difPy) Python package automates this task for you!

Read more on how the algorithm of difPy works in my Medium article Finding Duplicate Images with Python.

For a detailed usage guide, please view the official difPy Usage Documentation.


Description

DifPy searches for images in one or two different folders, compares the images it found and checks whether these are duplicates. It then outputs the image files classified as duplicates and the filenames of the duplicate images having the lower resolution, so you know which of the duplicate images are safe to be deleted. You can then either delete them manually, or let difPy delete them for you.

DifPy does not compare images based on their hashes. It compares them based on their tensors i. e. the image content - this allows difPy to not only search for duplicate images, but also for similar images.

Basic Usage

Use the following function to make difPy search for duplicates in one specified folder:

from difPy import dif
search = dif("C:/Path/to/Folder/")

To search for duplicates within two folders:

from difPy import dif
search = dif("C:/Path/to/Folder_A/", "C:/Path/to/Folder_B/")

Folder paths must be specified as a Python string.

Output

DifPy gives two types of output that you may use depending on your use case:

A dictionary of duplicates/similar images that were found:

search.result

> Output:
{"image1" : {"location" : "C:/Path/to/Image/image1.jpg"},
             "duplicates" : ["C:/Path/to/Image/duplicate_image1.jpg",
                             "C:/Path/to/Image/duplicate_image2.jpg"]},
...
}

A list of duplicates/similar images that have the lowest quality:

search.lower_quality

> Output:
["C:/Path/to/Image/duplicate_image1.jpg", 
 "C:/Path/to/Image/duplicate_image2.jpg", ...]

DifPy can also generate a dictionary with statistics on the completed process:

search.stats

> Output:
{"directory_1" : "C:/Path/to/Folder_A/",
 "directory_2" : "C:/Path/to/Folder_B/",
 "duration" : {"start_date": "2022-06-13",
               "start_time" : "14:44:19",
               "end_date" : "2022-06-13",
               "end_time" : "14:44:38",
               "seconds_elapsed" : 18.6113},
 "similarity_grade" : "normal",
 "similarity_mse" : 200,
 "total_images_searched" : 1032,
 "total_images_found" : 1024}

CLI Usage

You can make use of difPy through the CLI interface by using the following commands:

python dif.py -A "C:/Path/to/Folder_A/"

python dif.py -A "C:/Path/to/Folder_A/" -B "C:/Path/to/Folder_B/"

It supports the following arguments:

dif.py [-h] -A DIRECTORY_A [-B [DIRECTORY_B]] [-Z [OUTPUT_DIRECTORY]] [-s [{low,normal,high}]] 
       [-px [PX_SIZE]] [-p [{True,False}]] [-o [{True,False}]] [-so [{True,False}]] 
       [-d [{True,False}]] [-D [{True,False}]]

The output of difPy is then written to files and saved in the working directory, where "xxx" is a unique timestamp:

difPy_results_xxx.json
difPy_lower_quality_xxx.txt
difPy_stats_xxx.json

Additional Parameters

DifPy has the following optional parameters:

dif(directory_A, directory_B, similarity="normal", px_size=50, 
    show_progress=True, show_output=False, sort_output=False, delete=False, silent_del=False)

For a detailed usage guide, please view the official difPy Usage Documentation.

Metadata

Release files for difPy 2.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for difPy 2.4.1
File Size Uploaded Provenance Actions
difPy-2.4.1.tar.gz 9.8 kB Without provenance Details for difPy-2.4.1.tar.gz

Release files / difPy-2.4.1.tar.gz

Download URL difPy-2.4.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
082a54123843c18389807e9b5a65c55bf4d13028074a3e1378e65e4f69cf9ad6
BLAKE2b-256 checksum
How to use checksums
b3224015f00d6daa5cdde207b1e309c4413cf238e5ab9310b7f6bcf57f48f0d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Security for difPy 2.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.4.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page