Evaluating Image Dimensions

I'm attempting to have a rule that will evaluate a folder of images and determine if the image is mobile or desktop wallpaper. I'm using the sips utility to extract the height and width of the image then just doing a simple comparison. The last bit of the rule just applies a tag to the file - in this case it applies a "Mobile WP" tag. I have a similar rule for "Desktop WP" that basically does the same thing except if height/width is switched.

The script runs fine when ran from the command-line with the image file set as the argument. When forcing the rules to run from Hazel, nothing appears to happen, but upon checking the Console there do appear to be errors.

Any assistance would be much appreciated.

The script runs fine when ran from the command-line with the image file set as the argument. When forcing the rules to run from Hazel, nothing appears to happen, but upon checking the Console there do appear to be errors.

- Code: Select all
fn=$1
pixh=$(sips -g pixelHeight $fn)
pixw=$(sips -g pixelWidth $fn)
declare -i pixhval=$(echo ${pixh} | awk -F: ' { print $2 }')
declare -i pixwval=$(echo ${pixw} | awk -F: ' { print $2 }')
if [ $pixhval -gt $pixwval ]; then echo 'mobile'; exit 0; else echo 'desktop'; exit 1; fi
Any assistance would be much appreciated.