This repository contains a collection of scripts to manage photos, especially to find duplicates and visually similar images. The following tools are available:
convert-heic.shconverts HEIC files to JPEGcreate-hashdb.rbcreates a hash database of all files in a folder (see below for details)find-duplicates.rbfinds duplicate images (based on a HashDB)find-non-duplicates.rbfinds images that are in a folder and are not duplicates.find-visual-duplicates.rbfinds images that are visually similar (based on a HashDB); usefull e.g. for finding duplicate WhatsApp images that have a lower resolutionmark-unequal.rbmarks images in a hashdb that are known to not be duplicates (useful to reduce the number of false positives infind-visual-duplicates.rb)rename-photos.rbrenames photos to a standard filename format; guesses info from the filename and EXIF datarm-duplicates.rbremoves duplicate images (based on the output of afind-duplicates.rbrun)show-duplicates.rbshows duplicate images for manual inspection
All tools have a --help option that shows the available options.
Also, see below for an overview on how to find and process duplicate images using these tools.
Under fedora do the following:
sudo dnf install ruby-devel libexif-devel perl-Image-ExifTool vips vips-devel libheif-tools ImageMagick-devel gcc-c++
bundlerMany tools in this respository deal with duplicate or visually similar images. Generally this task can be quite time consuming, so the tools are split into three steps:
-
HashDB: A HashDB is a YAML file that contains various hashes and metadata of a number of images. This information will be the basis for finding duplicates or visually similar images. Use
create-hashdb.rbto create a HashDB for a folder. Usecreate-hashdb.rb --helpto learn more and see the available options. -
Finding duplicates: Based on a HashDB, you can find exact duplicates with
find-duplicates.rbor visually similar images withfind-visual-duplicates.rb. Both scripts output a YAML for further processing such as removing or manual inspection. It is recommended to pipe the output into a file for further processing. -
Processing duplicates: You can use
rm-duplicates.rbto remove duplicates orshow-duplicates.rbto show them for manual inspection. Or you can usefind-non-duplicates.rbto find images in a folder that are not duplicates (e.g. to make sure that you don't overlook an image). As finding visually similar images can create false positives, you can usemark-unequal.rbto mark images that are known to not be duplicates. Note that because the output of the previous step is a YAML file, you can easily manually edit it before feeding it into the above tools!
Generally, all tools are quite conservative meaning that they usually will not remove or alter any images without explicit options.