I need a command line tool that compares 2 images with identical names but from different folders and says if their pixel sizes are the same. It should go through all images and then outputs the list of images that don't have identical pixel sizes.
1 Answer
A little shell script that should do the job (not tested, might need some fine-tuning) – based on awk
(comes pre-installed with most Linux distributions) and exiftool
(available in the default repos):
#!/bin/bash
# pass this the two directories to compare
for pict in $dir1/*; do
pict2="${dir2}/${pict##*/}"
if [[ ! -f "$pict2" ]]; then
continue; # nothing to compare to; adjust if you want to do somthing here
fi
wid1=$(exiftool -ImageWidth -S $pict |awk '{print $NF}')
hei1=$(exiftool -ImageHeight -S $pict |awk '{print $NF}')
wid2=$(exiftool -ImageWidth -S $pict2 |awk '{print $NF}')
hei2=$(exiftool -ImageHeight -S $pict2 |awk '{print $NF}')
if [[ $wid1 -ne $wid2 || §hei1 -ne $hei2 ]]; then
echo "$pict and $pict2 differ" # adjust to the output you need
fi
done
exiftool
and àwk` be acceptable? I use something close to that for creating "previews" which could easily be adapted. It evaluates the dimensions in pixels (x:y) which is what you'd need to compare, but hust to figure whether it's landscape or portrait (which you could skip).wid=$(exiftool -ImageWidth -S $bild |awk '{print $NF}')
andhei=$(exiftool -ImageHeight -S $bild |awk '{print $NF}')
are the core facts you'd need;[[ $hei1 -ne $hei2 || $wid1 -ne $wid2 ]] && echo $filename
would then do your job.