jump to navigation

Shell script to prepare photos for the web July 9, 2007

Posted by maxmil in : bash , trackback

Just needed to optimize a folder of jpg’s for the Web. I needed to:

1) Reduce their dimensions so that their longest dimension was at most 700px.
2) Reduce their quality to 75%

Using the convert command that forms part of imagemagick this was easy. The script takes two parameters, an input directory and an output directory. Both without slashes.

if [ $# -ne 2 ]
echo "usage: $0 [input directory] [output directory]" >&2
for file in $1/*
convert $file -resize 700x700 -quality 75 $2/`basename $file`


no comments yet - be the first?