This way, image scaling can be automated for any number of images of type .jpg.
1 #!/bin/sh 2 3 # NAME : mkthumbs - script to scale images down 4 # 5 # USAGE : mkthumbs [dir] [scalefac] 6 # 7 # INPUTS : [dir] -> the directory with jpg files 8 # [scalefac] -> the factor to scale them down by 9 # 10 # OUTPUTS: scaled down .thumb.jpg files of same basename 11 # 12 # EXAMPLE: to scale down your cwd .jpg's by a factor of 8: 13 # % ./mkthumbs . 8 14 # 15 # $Id: mkthumbs,v 1.0 2001.01.28 14:50:59 tkralidi Exp $ 16 17 if [ $# -ne 2 ]; then 18 echo "Usage: $0 [dir] [scalefac]" 19 exit 1 20 fi 21 22 DJPEG="/usr/bin/djpeg" 23 CJPEG="/usr/bin/cjpeg" 24 25 echo "Working on .jpg files in $1" 26 27 for i in $1/*.jpg; do 28 if [ -f $i ]; then 29 echo "Scaling $i by $2" 30 $DJPEG -scale 1/$2 $i | $CJPEG > ${i%jpg}thumb.jpg 31 echo "${i%jpg}thumb.jpg created" 32 else 33 echo "No files in $1 of type .jpg" 34 echo "Exiting" 35 exit 2 36 fi 37 done 38 39 echo "Done" 40 41 exit 0 |