How do you use "sips" at the terminal to resize an image, without upscaling?

Process the output of sips --getProperty pixelHeight filename.ext and sips --getProperty pixelWidth filename.ext and use it in a condition, only performing the resize operation if desired.


#!/bin/bash
height=`sips --getProperty pixelHeight url.png | sed -E "s/.*pixelHeight: ([0-9]+)/\1/g" | tail -1`
width=`sips --getProperty pixelWidth url.png | sed -E "s/.*pixelWidth: ([0-9]+)/\1/g" | tail -1`

if [[ $height -gt 500 || $width -gt 500 ]]; then
    growlnotify -m "large file needs reducing"
fi

You can do the rest on your own.