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.

  • As you're on Linux: would a Bash script utilizing 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}') and hei=$(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.
    – Izzy
    Oct 21, 2022 at 6:58

1 Answer 1


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):

# pass this the two directories to compare

for pict in $dir1/*; do
  if [[ ! -f "$pict2" ]]; then
    continue; # nothing to compare to; adjust if you want to do somthing here
  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
  • There's no need to start 2 exiftool and 2 awk processes per file, try exiftool -p '$ImageWidth $ImageHeight' IMAGE.JPG Jun 22, 2023 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.