Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Drag-and-drop script to quickly resize any image' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Drag-and-drop script to quickly resize any image
Authored by: ludojad on Jul 14, '09 02:32:27AM

Here's quick script in bash which resizes images to the same size no matter if they are horizontal or vertical.
Remeber to set SIZE variable to desired size.


# Call this script and use it this way:
# for i in ./*.JPG ; do $i ; done

GETWIDTH=`sips --getProperty pixelWidth $1 | cut -s -d : -f 2 -`
GETHEIGHT=`sips --getProperty pixelHeight $1 | cut -s -d : -f 2 -`

# If image is horizontal then
if [ $GETWIDTH -gt $GETHEIGHT ] ; then
sips --resampleWidth $SIZE $1 2>&1>/dev/null
# Image is vertical
sips --resampleHeight $SIZE $1 2>&1>/dev/null

[ Reply to This | # ]