Skip to main content

difPy Python Duplicate Image Finder - searches for duplicate or similar images within folders.

Project description

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 more different folders, compares the images it found and checks whether these are duplicates. It then outputs the image files classified as duplicates as well as the images having the lowest resolutions, 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 within one specific folder and its subfolders:

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

To search for duplicates within mutliple folders and their subfolders:

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

Folder paths must be specified as standalone Python strings, or within a Python list.

Output

DifPy returns various types of output that you may use depending on your use case:

A JSON formatted collection of duplicates/similar images (i. e. match groups) that were found, where the keys are a randomly generated unique id for each image file:

search.result

> Output:
{20220819171549 : {"location" : "C:/Path/to/Image/image1.jpg",
                   "matches" : {30270813251529 : "location": "C:/Path/to/Image/matched_image1.jpg",
                                                 "mse": 0.0},
                               {72214282557852 : "location": "C:/Path/to/Image/matched_image2.jpg",
                                                 "mse": 0.0},
                   ... }
 ...
}

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

search.lower_quality

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

A JSON formatted collection with statistics on the completed difPy process:

search.stats

> Output:
{"directory" : ("C:/Path/to/Folder_A/", "C:/Path/to/Folder_B/", ... ),
 "duration" : {"start_date": "2023-02-15",
               "start_time" : "18:44:19",
               "end_date" : "2023-02-15",
               "end_time" : "18:44:38",
               "seconds_elapsed" : 18.6113},
 "fast_search": True,
 "recursive" : True,
 "match_mse" : 200,
 "files_searched" : 1032,
 "matches_found" : 852,
 "invalid_files": {"count": 4}}

Additional Parameters

DifPy supports the following parameters:

dif(*directory, fast_search=True, recursive=True, similarity='normal', px_size=50, 
    move_to=None, show_progress=True, show_output=False, delete=False, silent_del=False, 
    logs=False)

CLI Usage

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

python dif.py -D "C:/Path/to/Folder/"

python dif.py -D "C:/Path/to/Folder_A/" "C:/Path/to/Folder_B/" "C:/Path/to/Folder_C/"

It supports the following arguments:

dif.py [-h] -D DIRECTORY [-Z OUTPUT_DIRECTORY] [-f {True,False}]
       [-r {True,False}] [-s SIMILARITY] [-px PX_SIZE] 
       [-p {True,False}] [-o {True,False}] [-mv MOVE_TO]
       [-d {True,False}] [-sd {True,False}] [-l {True,False}]

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

difPy_results_xxx.json
difPy_lower_quality_xxx.csv
difPy_stats_xxx.json

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

Project details


Download files

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

Source Distribution

difPy-3.0.7.tar.gz (13.2 kB view details)

Uploaded Source

File details

Details for the file difPy-3.0.7.tar.gz.

File metadata

  • Download URL: difPy-3.0.7.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for difPy-3.0.7.tar.gz
Algorithm Hash digest
SHA256 d616a134426b19a1c28659a6c7a909bd6fb74514e4580c6be61b4d023880ccef
MD5 fe7f662668b2f3c1d0d9cecf4817f944
BLAKE2b-256 423671556c11e00faca94ed76e557d28793251ac5687d8c67424bf7aad17aff2

See more details on using hashes here.

Supported by

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