Iterate over an array of image sizes, and move them to a new folder

So a few years ago a asked this question, on how to find an image of specific dimensions. That script worked (and works) great for me! But now, i want to find not just one (1) dimensions but 10 different dimensions. And with my current setup and system, and iteration of a specific dimensions takes about one (1) hour.

I have multipel executables of the same script, but i run them after each other ./delete180x180images && ./delete800x600images and so on.

Is it possible to compare the image dimensions agains an array? example DIMENSIONS=('120x120' '269x360' '360x269'), and if there is a match, move that file?

This is the script from my previous question that i currently use:

#!/bin/bash
targetDir="$HOME/Pictures/iPhoto-bibliotek.photolibrary"

HEIGHT=450
WIDTH=600

echo -e "Scanning \033[0;32m$targetDir\033[0m"
find $targetDir -type f \( -iname \*.jpg -o -iname \*.png -iname \*.bmp -iname \*.jpeg \) 2>/dev/null | \
while read -r filename; do
    hw="$(sips -g pixelHeight -g pixelWidth "$filename" 2>/dev/null)"
    h="$(awk '/pixelHeight/{print $2}'<<<"$hw")"
    w="$(awk '/pixelWidth/{print $2}'<<<"$hw")"
    if [[ $h -eq $HEIGHT ]] && [[ $w -eq $WIDTH ]]; then
        echo mv "$filename" $(pwd)/120x120images
    fi
done

Solution 1:

#!/bin/bash
targetDir="$HOME/Pictures/iPhoto-bibliotek.photolibrary"

echo -e "Scanning \033[0;32m$targetDir\033[0m"
find $targetDir -type f \( -iname \*.jpg -o -iname \*.png -iname \*.bmp -iname \*.jpeg \) 2>/dev/null | \
    while read -r filename; do
        hw="$(sips -g pixelHeight -g pixelWidth "$filename" 2>/dev/null)"
        h="$(awk '/pixelHeight/{print $2}'<<<"$hw")"
        w="$(awk '/pixelWidth/{print $2}'<<<"$hw")"

        case ${h}x${w} in
            450x600) echo mv "$filename" $(pwd)/120x120images
                     ;;
            120x120) echo mv "$filename" $(pwd)/120x120images
                     ;;
            269x360) echo mv "$filename" $(pwd)/120x120images
                     ;;
            *)       echo "$filename ignored"
                     ;;
        esac
done

You can add additional dimensions in the same way, or change the target directory if required. Also, remove the echo once it works.