This is a Rust command-line tool to find similar images within a specified folder and its subfolders. It uses perceptual hashing algorithms to compare images and can perform different actions (print, move, copy, or delete similar images) based on user choice.
- Recursively finds images in folders (supports jpg, jpeg, png, bmp, webp, tiff, tif, ico, avif [if avif feature is enabled]).
- Calculates perceptual hashes of images using the
image-hasher
crate. - Computes hashes in parallel for speed.
- Groups similar images using the Disjoint Set Union (DSU) algorithm.
- Provides different actions to handle groups of similar images:
print
: Prints the paths of similar images.move
: Moves similar images to a specified target folder (one subfolder per group).copy
: Copies similar images to a specified target folder (one subfolder per group).delete
: Deletes all but the largest file (by size) in each group of similar images.
- Configurable similarity threshold.
- Displays a progress bar.
Ensure you have Rust and Cargo installed.
git clone <repository-url>
cd similarImgDetect
cargo build --release
To support AVIF images, you need to follow these steps:
-
Install
pkg-config
andvcpkg
through chocolatey or scoopchoco install pkgconfiglite choco install vcpkg
or
scoop install pkg-config scoop install vcpkg
-
Install
dav1d
vcpkg install dav1d:x64-windows
-
Add to the
PKG_CONFIG_PATH
environment variable the path$VCPKG_INSTALLATION_ROOT\installed\x64-windows\lib\pkgconfig
-
Build code
git clone <repository-url>
cd similarImgDetect
cargo build --release --features avif
To speed up the computation, you can build your packages only in Release
mode
adding the set(VCPKG_BUILD_TYPE release)
line to the
$VCPKG_INSTALLATION_ROOT\triplets\x64-windows.cmake
file.
Building for Windows x86 is the same, just replace x64
with x86
in the
steps above.
./target/release/similarImgDetect --path <image-folder> [options]
-p, --path <path>
: Path to the folder containing images (required).-s, --similarity <similarity>
: Similarity threshold for image comparison (float between 0-1, default: 0.9). Higher values mean more similarity is required.-a, --action <action>
: Action to perform after finding similar images (default:print
).print
: Print the paths of similar images.move
: Move similar images to the folder specified by--target-path
.copy
: Copy similar images to the folder specified by--target-path
.delete
: Delete all but the largest file in each group of similar images.
-t, --target-path <target_path>
: Path to the target folder for moving/copying similar images whenaction
ismove
orcopy
.
-
Print groups of images with similarity >= 0.95 in the
/path/to/images
folder:./target/release/similarImgDetect -p /path/to/images -s 0.95 -a print
Or (since
print
is the default action):./target/release/similarImgDetect -p /path/to/images -s 0.95
-
Move images with similarity >= 0.9 from
/path/to/images
to/path/to/similar_images
(one subfolder per group):./target/release/similarImgDetect -p /path/to/images -a move -t /path/to/similar_images
-
Copy images with similarity >= 0.85 from
/path/to/images
to/path/to/duplicates
:./target/release/similarImgDetect -p /path/to/images -s 0.85 -a copy -t /path/to/duplicates
-
Delete similar images with similarity >= 0.98 in
/path/to/images
(keeping the largest file in each group):./target/release/similarImgDetect -p /path/to/images -s 0.98 -a delete
clap
: For command-line argument parsing.image-hasher
: For generating image hashes.image
: For image loading and processing.rayon
: For parallel processing.indicatif
: For displaying progress bars.