Automating scaling tasks
On Sat, 2005-04-02 at 15:26 -0800, Richard C. Steffens wrote:
Is there a set of instructions for automating the task of scaling images?
I have a large number of images that I want to scale to three different sizes.
I successfully do this manually, and it doesn't take too long, but I'd like
to find (or create -- but I can't imagine someone hasn't already done this) a
script to run that will do this for me.
I would point the Gimp to a directory containing links to images, and have the
script cycle through all the images, creating three copies of each image,
each scaled to a different size and leaving them in that directory. To get
even fancier, I'd save each size in a sub-directory.
Thanks for helping a Gimp newbie.
ImageMagick is your friend here. It's specifically designed for just
the type of batch operations you're wanting. Check out
man convert
man mogrify
and
man ImageMagick for more details.
Basically you would write a quick shell script along these lines:
#!/bin/bash
indir=/directory/with/original/pix
bigpix=/direceory/with/big/output
medpix=/directory/with/med/pix
thumbpix=/directory/with/thumbnail/pix
thisdir=`pwd`
cd $indir
for $img in *.jpg
do
convert -size 800x800 -resize 800x800 $img $bigpix/$img_big.jpg
convert -size 640x640 -resize 640x640 $img $medpix/$img_med.jpg
convert -size 120x120 -resize 120x120 $img $thumbpix/$img_thumb.jpg
done
cd $thisdir
# end of bash script
HTH,