iPhone image resize and auto-upload with Hazel and ImageMagick


I made a slight alteration to my automatic image resize and upload workflow which uses Hazel and ImageMagick to automatically upload images placed in a certain directory to my FTP server so I can link to them online. The alteration checks to see if they’re iPhone 5 screenshots, and if so it makes them a little smaller than usual (because iPhone 5 screen caps are so long.)

Here’s the updated code:

cd /usr/local/bin
dimensions=`identify -format "%w%h" "$1"`
if [ $dimensions -eq "6401136" ]
then
    mogrify -density 360 -resize 300x450\> "$1"
else
    mogrify -density 360 -resize 650x800\> "$1"
fi

This makes use of the helpful “identify” command that ImageMagick provides.