The gimp currently is a sub-optimal program for batch processing.  If
you're really talking thousands of pics, look elsewhere.  There should
be some good stand-alone C/C++ libraries for image processing--I imagine
that those coming with the Gimp are rather specialized.

However, at the bottom of this message is included a bash script for
scaling *.bmp images with Gimp 1.1.23.  Batch scripting with the Gimp is
currently rather slow because the program reloads for each picture.  I
have some ideas for getting around this (i.e. 1 BIG instruction line,
some other possibilities) but am leaving them for later or someone
else.  [whichever comes first ;-)]

The script should be easily modified to work with all image types. 
Basically, you should only have to change the gimp-file-save
instruction.  To start, play with #'s in the range 0-10 where the 2
currently is.

Have fun,
Daniel Herring
[EMAIL PROTECTED]

P.S>  Many thanks to Alan Buxey for getting me headed down the right
scripting path.

Following is the script.
Make sure the line starting with "gimp -n" and ending with "\" is
restored to 1 line.
_________________________________
#!/usr/bin/bash
#Edit this first line to show the directory to your shell environment
#You can get this from issuing the command `echo $SHELL` or `which bash`
...

#NOTE: If this script gives a "permission denied" error, did you issue
`chmod 755 scaleFilter.sh`?
#      Are you calling it as `./scaleFilter.sh` in the directory
containing the images to be changed?


#Constants --don't edit
FALSE=0
TRUE=1

#########################
#Edit these variables as needed
files=`ls *.bmp` # modify to change different images

backup=$FALSE # $TRUE or $FALSE --do you want a backup?
backupDIR=orig # name of backup directory --use a plain . for current
directory

scale=2 # scalar multiplier for the image (newWidth=width*scale...) must
be greater than 0

#Don't edit past here.
#########################
path=`pwd`

for file in $files
do
        echo "Processing $file"

#       Backup?
        if [ $backup -eq $TRUE ]
        then
                if test -e $backupDIR
                then
                        cp $file $backupDIR/$file
                else
                        echo "Making backup directory"
                        mkdir $backupDIR
                        cp $file $backupDIR/$file
                fi
        fi

    gimp -n --verbose -b "(begin (set! theImage (car (gimp-file-load 1
\"$path/$file\" \"$file\")))(set! height (* $scale (car
(gimp-image-height theImage))))(set! width (* $scale (car
(gimp-image-width theImage))))(gimp-image-scale theImage height
width)(set! theDrawable (gimp-image-active-drawable
theImage))(gimp-file-save 1 theImage 2 \"$path/$file\" \"$file\"))" \
                '(gimp-quit 1)'

done

#Script released under the GPL on 6-19-2000 by Daniel Herring
([EMAIL PROTECTED])
#This script works with the Gimp version 1.1.23
#It will not work under version 1.0.4 without some editing (I think)

Reply via email to