Is it possible for findimagedupes compare images in one folder with another?

For example, in one folder 100 images, and in another as much. In the first folder there is one image, more than 85%, similar to one image in another folder.

I tried to do this:

 findimagedupes -t 85 "первая_папка/*" "вторая_папка/*" 

but the fact is that it shows the matches that were found in the first folder and / or in the second. And it is necessary to inform that "a image was found in the folder first_folder , which coincides with the image in second_folder "

    1 answer 1

    You can loop through all the pairs of files:

     $ for f1 in первый_каталог/*; do \ for f2 in второй_каталог/*; do \ findimagedupes -t 85 $f1 $f2; done; done 

    if it is required that the pairs of files in the output lines are not mixed (the first file can be either the first or the second directory), then each line can be sorted using the program findimagedupes transfer the received lines to the specified script for processing (see man findimagedupes ):

     $ for f1 in первый_каталог/*; do \ for f2 in второй_каталог/*; do \ findimagedupes -t 85 -i \ 'VIEW(){ for f in "$@"; do echo $f; done | sort | xargs echo; }' -- \ $f1 $f2; done; done 

    this sort of each one is pretty resource intensive ( fingerprints are calculated every time you start), so for greater optimality you should either add the program itself with the necessary functionality, or by calling it for all files at once, somewhat complicate the script passed to the program by the option -i .


    update

    "Complicated" script:

     #!/bin/bash d1=$(realpath $1) d2=$(realpath $2) e1=$(echo $d1 | sed 's,/,\\/,g') findimagedupes -t 85 -i 'VIEW() { n1=$(for f in "$@"; do echo $f; done \ | sed -n "/^'$e1'/{p;q}"); n2=$(for f in "$@"; do echo $f; done \ | grep "^'$d2'" | xargs echo); if [ -n "$n1" -a "$n2" ]; then \ for f in "$@"; do echo $f; done | sed -n "/^'$e1'/!{s|^|$n1 |;p}"; fi; \ }' $d1/* $d2/* 

    it is called with two parameters: первый_каталог второй_каталог (without any masks, just directory paths). for each line generated by the program, it leaves only one file from the first directory (the first one encountered), but splits it into several lines so that in each resulting line there is only one file from the second directory.

    for example, it replaces the string dir1/file1 dir1/file2 dir2/file1 dir2/file2 with two lines:

     dir1/file1 dir2/file1 dir1/file1 dir2/file2 

    and, of course, lines that contain only files from the first or only from the second directory are ignored.