"Easy to use" user interfaces are the worst thing that ever happened to people in their interactions with computers. The GUI enslaves you. If you have a hundred images to process, you don't want an "intuitive" user interface that makes it easy for you to sit at the computer all day and all night working. You want a batch script that will do the processing while you're away from the computer occupied in activities fit for a person.
The GIMP is a powerful image manipulation program. Its scripting language is called "Script-Fu," and Scripts-Fu, together with conventional shell (bash) scripts, can accomplish these tasks of automation. These scripts aren't really that hard once they're written, but the process is not well documented and the debugging facilities are quite minimal. I wrote the first of these several years ago, and found the process to be relatively painful. The others are just modified versions of the first one. I keep losing them, so I figure that if I put them online I'll always be able to find them.
Each of these scripts (except one) performs a single GIMP function (rotating, scaling, etc.), reading its input from an image file and writing its output to a new image file. They can be plumbed together in a shell script to accomplish more complex tasks (e.g., rotate then scale then convert to JPEG). This technique of single-function Scripts-Fu and shell scripting is not efficient - The GIMP must be started each time, which has an overhead, and the reading and writing of image files takes time. It would be more efficient to write more complex Scripts-Fu to perform multiple tasks within a single GIMP invocation. Efficiency isn't the point here, though. These scripts are intended for batch processing of many files, and, within reason, it doesn't matter how long the process takes. Since I'm still better at shell programming than Script-Fu programming, I put the complexity in the shell scripts.
The only exception to the above is "script-fu-dmm-old-photo," which performs two logical operations (fuzzy border and color balance), but even it is structured as a file filter.
Other packages, such as NetPBM and ImageMagick, may be more efficient at some or all of the tasks done by these Scripts-Fu. In several cases, I've included notes on the use of ImageMagick tools.
I'm sure that these scripts contain many bugs, and that they could be improved considerably. The shell scripts for invoking the Script-Fu scripts do no sanity checking at all on their input. These scripts were developed with The GIMP 1.2. At the time of writing, The GIMP 2 has just been released; we'll see how they break then.
These scripts are licensed under the GNU GPL. In addition, if you modify these scripts, I would ask that as a courtesy you rename them using a prefix other than "dmm" and that you modify the "script-fu-register" information appropriately. Thank you.
You may need to right-click on the filenames to save the file versions to your computer. Don't cut-and-paste from the screen, as characters such as "<" and "&" have been replaced in this XHTML file with XML entities.
WARNINGS
These scripts and/or commands could destroy your data! You never can tell, after all. If you chose to use them, or scripts derived from them, you do so entirely at your own risk. Operate only on copies of your data, never on the originals, and back up the originals anyway to safe media before even working on the copies.
These scripts and/or commands should never be run on any computer which may be subject to security concerns of any type. All computers with network connections to the public Internet are subject to security concerns. Make certain that you have uncompromised copies of these scripts - read and understand them!
The ImageMagick "identify" command is very handy for determining the XY pixel size of an image without opening up an image viewer. Knowing these dimensions, in turn, is very handy when writing (X)HTML by hand.
GIMP Script-Fu "dmmScalePNG.scm":
; dmmScalePNG.scm - GIMP Script-Fu to Scale a PNG Image to a New Width
; This Script-Fu must be put in The GIMP's script directory
; (e.g., $HOME/.gimp-1.2/scripts).
; For command-line invocation, use the shell script dmmScalePNG.sh
; For interactive invocation, run The GIMP and go to
; Xtns -> Script-Fu -> dmm
; New width is in pixels
;
(define (dmmScalePNG newwidth infile outfile)
(let* ((image (car (file-png-load 1 infile infile)))
(drawable (car (gimp-image-active-drawable image)))
(oldwidth (car (gimp-image-width image)))
(oldheight (car (gimp-image-height image)))
(newheight (* newwidth (/ oldheight oldwidth)))
)
(gimp-image-scale image newwidth newheight)
(file-png-save 1 image drawable outfile outfile
1 0 0 0 0 0 0 )
; 1 Adam7 interlacing?
; 0 deflate compression factor (0-9)
; 0 Write bKGD chunk?
; 0 Write gAMMA chunk?
; 0 Write oFFs chunk?
; 0 Write tIME chunk? ?? backwards in DB Browser
; 0 Write pHYS chunk? ?? backwards in DB Browser
)
)
(script-fu-register ; I always forget these ...
"dmmScalePNG" ; script name to register
"<Toolbox>/Xtns/Script-Fu/dmm/dmmScalePNG" ; where it goes
"dmm Scale PNG" ; script description
"David M. MacMillan" ; author
"Copyright 2002 by David M. MacMillan; GNU GPL" ; copyright
"2002-07-22" ; date
"" ; type of image
SF-VALUE "NewWidth" "100" ; default parameters
SF-FILENAME "Infile" "infile.png"
SF-FILENAME "Outfile" "outfile.png"
)
Shell Script "dmmScalePNG.sh" to invoke "dmmScalePNG.scm":
# dmmScalePNG.sh # Invoke The GIMP with Script-Fu dmmScalePNG.scm # No error checking. if [ -e $1 ] then echo "Usage: dmmScalePNG.sh width filebasename" echo "Error: Parameter 1 (new width in pixels) required" exit 1 fi if [ -e $2 ] then echo "Usage: dmmScalePNG.sh width filebasename" echo "Error: Parameter 2 (filename base) required" exit 1 fi gimp -c -i -d -b "(dmmScalePNG $1 \"$2.png\" \"$2-scale$1.png\")" "(gimp-quit 0)"
Script-Fu: dmmScalePNG.scm
Shell Script: dmmScalePNG.sh
To use another approach, the ImageMagick "mogrify" command can rescale an image (or multiple images). Be VERY careful in using it, though, because unless you are also changing the image format (e.g., PNG to JPEG), mogrify overwrites the original image file. Even if you access an image from a different directory (for example, a subdirectory) it will write (or overwrite) its output in the same directory where the original image resides. You should of course make backup copies of your images before using this command.
Example: Use mogrify to resize all PNG (.png) images in a directory to 20 percent of their original width and then write the output images as JPG (.jpg) files with the same base name and the ".jpg" extension. This might be used, for example, to create smaller preview images for a set of very large image files.
mogrify -format jpg -resize 20x% *.png
By way of contrast, if I had specified, say, PNG for both the input and output images, or not specified an output image format, my original images would be gone forever. It is a characteristic of powerful tools that you can hurt yourself with them.
Note: The ImageMagick "convert" program may also be used to resize an image. Using "convert" has the advantage that since the output format must be different (that's the whole point of conversion, after all), the original file clearly cannot be overwritten.
GIMP Script-Fu "dmmRotatePNG.scm":
; dmmRotatePNG - GIMP Script-Fu to Rotate a PNG
; This Script-Fu must be put in The GIMP's script directory
; (e.g., $HOME/.gimp-1.2/scripts).
; For command-line invocation, use the shell script dmmRotatePNG.sh
; For interactive invocation, run The GIMP and go to
; Xtns -> Script-Fu -> dmm
; Positive rotation is clockwise, and is specified in degrees (not radians)
;
(define (dmmRotatePNG rotatedegrees infile outfile)
(let* ((image (car (file-png-load 1 infile infile)))
(drawable (car (gimp-image-active-drawable image)))
(rotateradians (* rotatedegrees (/ 3.14159 180)))
)
(gimp-rotate drawable 0 rotateradians)
(file-png-save 1 image drawable outfile outfile
1 0 0 0 0 0 0 )
; 1 Adam7 interlacing?
; 0 deflate compression factor (0-9)
; 0 Write bKGD chunk?
; 0 Write gAMMA chunk?
; 0 Write oFFs chunk?
; 0 Write tIME chunk? ?? backwards in DB Browser
; 0 Write pHYS chunk? ?? backwards in DB Browser
)
)
(script-fu-register ; I always forget these ...
"dmmRotatePNG" ; script name to register
"<Toolbox>/Xtns/Script-Fu/dmm/dmmRotatePNG" ; where it goes
"dmm Rotate PNG" ; script description
"David M. MacMillan" ; author
"Copyright 2002 by David M. MacMillan; GNU GPL" ; copyright
"2002-07-22" ; date
"" ; type of image
SF-VALUE "Rotate Degrees" "90" ; default parameters
SF-FILENAME "Infile" "infile.png"
SF-FILENAME "Outfile" "outfile.png"
)
Shell script "dmmRotatePNG.sh" to invoke GIMP Script-Fu "dmmRotatePNG.scm":
# dmmRotatePNG.sh # Invoke The GIMP with Script-Fu dmmRotatePNG.scm # No error checking. if [ -e $1 ] then echo "Usage: dmmRotatePNG.sh degrees filebasename" echo "Error: Parameter 1 (rotate degrees clockwise) required" exit 1 fi if [ -e $2 ] then echo "Usage: dmmRotatePNG.sh degrees filebasename" echo "Error: Parameter 2 (filename base) required" exit 1 fi gimp -c -i -d -b "(dmmRotatePNG $1 \"$2.png\" \"$2-rot$1.png\")" "(gimp-quit 0)"
Script-Fu: dmmRotatePNG.scm
Shell Script: dmmRotatePNG.sh
To use another approach, the ImageMagick "mogrify" command can rotate an image (or multiple images). Be VERY careful in using it, though, because unless you are also changing the image format (e.g., PNG to JPEG), mogrify overwrites the original image file. Even if you access an image from a different directory (for example, a subdirectory) it will write (or overwrite) its output in the same directory where the original image resides. You should of course make backup copies of your images before using this command.
Example: Use mogrify to resize a single PNG (.png) image 90 degrees clockwise. Write the output as a PNG, and take care not to allow mogrify to overwrite the original file (do this by making a copy FIRST, then working on the copy, and then renaming the copy; one could make the copy initially under the new name and save a step here, but I find that mode of operation to be potentially confusing). Assume that no file with the copy's filename pre-exists.
# make and verify safe backup copy to external medium first! # only then cp test.png temp.png mogrify -format png -rotate 90 temp.png mv temp.png test-rotate90.png
Note: The ImageMagick "convert" program may also be used to resize an image. Using "convert" has the advantage that since the output format must be different (that's the whole point of conversion, after all), the original file clearly cannot be overwritten.
GIMP Script-Fu "dmmConvertPNGtoGrayscale.scm":
; dmmPNGtoGrayscale - GIMP Script-Fu to convert a PNG image to Grayscale
; This Script-Fu must be put in The GIMP's script directory
; (e.g., $HOME/.gimp-1.2/scripts).
; For command-line invocation, use the shell script dmmToGrayscale.sh
; For interactive invocation, run The GIMP and go to
; Xtns -> Script-Fu -> dmm
;
(define (dmmPNGtoGrayscale infile outfile)
(let* ((image (car (file-png-load 1 infile infile)))
(drawable (car (gimp-image-active-drawable image)))
)
(gimp-convert-grayscale image)
(file-png-save 1 image drawable outfile outfile
1 0 0 0 0 0 0 )
; 1 Adam7 interlacing?
; 0 deflate compression factor (0-9)
; 0 Write bKGD chunk?
; 0 Write gAMMA chunk?
; 0 Write oFFs chunk?
; 0 Write tIME chunk? ?? backwards in DB Browser
; 0 Write pHYS chunk? ?? backwards in DB Browser
)
)
(script-fu-register ; I always forget these ...
"dmmPNGtoGrayscale" ; script name to register
"<Toolbox>/Xtns/Script-Fu/dmm/dmmPNGtoGrayscale" ; where it goes
"dmm PNG (RGB or Indexed) to Grayscale" ; script description
"David M. MacMillan" ; author
"Copyright 2004 by David M. MacMillan; GNU GPL" ; copyright
"2004-02-08" ; date
"" ; type of image
SF-FILENAME "Infile" "infile.png" ; default parameters
SF-FILENAME "Outfile" "outfile.png"
)
Shell script "dmmConvertPNGtoGrayscale.sh" to invoke GIMP Script-Fu "dmmPNGtoGrayscale.scm":
# dmmPNGtoGrayscale.sh # Invoke The GIMP with Script-Fu dmmPNGtoGrayscale.scm # No error checking. if [ -e $1 ] then echo "Usage: dmmPNGtoGrayscale.sh degrees filebasename" echo "Error: Parameter (filename base) required" exit 1 fi gimp -c -i -d -b "(dmmPNGtoGrayscale \"$1.png\" \"$1-gray.png\")" "(gimp-quit 0)"
Script-Fu: dmmPNGtoGrayscale.scm
Shell Script: dmmPNGtoGrayscale.sh
GIMP Script-Fu "dmmConvertJPGtoPNG.scm":
; dmmConvertPNGtoJPG.scm - GIMP Script-Fu to Convert PNG to JPG
; This Script-Fu must be put in The GIMP's script directory
; (e.g., $HOME/.gimp-1.2/scripts).
; For command-line invocation, use the shell script dmmConvertPNGtoJPG.sh
; For interactive invocation, run The GIMP and go to
; Xtns -> Script-Fu -> dmm
;
(define (dmmConvertPNGtoJPG infile outfile)
(let* ((image (car (file-png-load 1 infile infile)))
(drawable (car (gimp-image-active-drawable image)))
)
(file-jpeg-save 1 image drawable outfile outfile
0.75 0 1 1 "GIMP" 0 1 0 0 )
; 0.75 quality (float 0 <= x <= 1)
; 0 smoothing factor (0 <= x <= 1)
; 1 optimization of entropy encoding parameter (0/1)
; 1 enable progressive jpeg image loading (0/1)
; "xxxx" image comment
; 0 subsampling option number
; 1 force creation of a baseline JPEG
; 0 frequency of restart markers
; in rows, 0 = no restart markers
; 0 DCT algoritm to use
)
)
(script-fu-register ; I always forget these ...
"dmmConvertPNGtoJPG" ; script name to register
"<Toolbox>/Xtns/Script-Fu/dmm/dmmConvertPNGtoJPG" ; where it goes
"dmm Convert PNG to JPG" ; script description
"David M. MacMillan" ; author
"Copyright 2004 by David M. MacMillan; GNU GPL" ; copyright
"2004-01-27" ; date
"" ; type of image
SF-FILENAME "Infile" "infile.png" ; default parameters
SF-FILENAME "Outfile" "outfile.png"
)
Shell script "dmmConvertJPGtoPNG.sh" to invoke GIMP Script-Fu "dmmConvertJPGtoPNG.scm":
# dmmConvertPNGtoJPG.sh # Invoke The GIMP with Script-Fu dmmConvertPNGtoJPG.scm # No error checking. if [ -e $1 ] then echo "Usage: dmmConvertPNGtoJPG.sh filebasename" echo "Error: Parameter 1 (filename base) required" exit 1 fi gimp -c -i -d -b "(dmmConvertPNGtoJPG \"$1.png\" \"$1.jpg\")" "(gimp-quit 0)"
Script-Fu: dmmConvertJPGtoPNG.scm
Shell Script: dmmConvertJPGtoPNG.sh
The use of the ImageMagick "convert" program to convert a JP(E)G image to PNG format is straightforward, and is described in the ImageMagick documentation.
Note: This script has not been tested on Indexed images, which require an Export to RGB or Greyscale before conversion to JPEG. I'd be very surprised if it worked on such images, but they may be converted using the dmmPNGtoGrayscale.scm Script-Fu.
GIMP Script-Fu "dmmConvertPNGtoJPG.scm":
; dmmConvertPNGtoJPG.scm - GIMP Script-Fu to Convert PNG to JPG
; This Script-Fu must be put in The GIMP's script directory
; (e.g., $HOME/.gimp-1.2/scripts).
; For command-line invocation, use the shell script dmmConvertPNGtoJPG.sh
; For interactive invocation, run The GIMP and go to
; Xtns -> Script-Fu -> dmm
;
(define (dmmConvertPNGtoJPG infile outfile)
(let* ((image (car (file-png-load 1 infile infile)))
(drawable (car (gimp-image-active-drawable image)))
)
(file-jpeg-save 1 image drawable outfile outfile
0.75 0 1 1 "GIMP" 0 1 0 0 )
; 0.75 quality (float 0 <= x <= 1)
; 0 smoothing factor (0 <= x <= 1)
; 1 optimization of entropy encoding parameter (0/1)
; 1 enable progressive jpeg image loading (0/1)
; "xxxx" image comment
; 0 subsampling option number
; 1 force creation of a baseline JPEG
; 0 frequency of restart markers
; in rows, 0 = no restart markers
; 0 DCT algoritm to use
)
)
(script-fu-register ; I always forget these ...
"dmmConvertPNGtoJPG" ; script name to register
"<Toolbox>/Xtns/Script-Fu/dmm/dmmConvertPNGtoJPG" ; where it goes
"dmm Convert PNG to JPG" ; script description
"David M. MacMillan" ; author
"Copyright 2004 by David M. MacMillan; GNU GPL" ; copyright
"2004-01-27" ; date
"" ; type of image
SF-FILENAME "Infile" "infile.png" ; default parameters
SF-FILENAME "Outfile" "outfile.png"
)
Shell script "dmmConvertPNGtoJPG.sh" to invoke GIMP Script-Fu "dmmConvertPNGtoJPG.scm":
# dmmConvertPNGtoJPG.sh # Invoke The GIMP with Script-Fu dmmConvertPNGtoJPG.scm # No error checking. if [ -e $1 ] then echo "Usage: dmmConvertPNGtoJPG.sh filebasename" echo "Error: Parameter 1 (filename base) required" exit 1 fi gimp -c -i -d -b "(dmmConvertPNGtoJPG \"$1.png\" \"$1.jpg\")" "(gimp-quit 0)"
Script-Fu: dmmConvertPNGtoJPG.scm
Shell Script: dmmConvertPNGtoJPG.sh
The use of the ImageMagick "convert" program to convert a JP(E)G image to PNG format is straightforward, and is described in the ImageMagick documentation.
GIMP Script-Fu "script-fu-dmm-old-photo.scm":
; script-fu-dmm-old-photo
; A file-filter script to make an image look like an old, worn, photograph.
; The core operations here are adapted from Chris Gutteridge's
; script-fu-old-photo, distributed stock with The GIMP 1.2,
; but with many changes.
;
; script-fu-dmm-old-photo puts a fuzzy border around the image and
; modifies the color balance (the default conversion is to "sepia").
; Values controlling these two transformations are supplied as parameters
; (this makes it easy to use this script for, say, blending in to web page
; backgrounds of any solid color; it is also nice for batch scripting).
;
; (If all you need to do is use the fuzzy border interactively for
; blending into a background, using Gutteridge's script-fu-fuzzy-border
; interactively would be easier.)
;
; Parameters:
; border-width fuzzy border width, in pixels, integer
; granularity granularity within fuzzy border, integer
; (see script-fu-fuzzy-border below)
; Example: 10 2 gives a 10 pixel fuzzy border
; 10 8 gives a 10 pixel fuzzy border, but the
; image runs up against the edge sharply; not good
; border-red fuzzy border color, RGB triplet in integers or floats
; border-green
; border-blue
; cyan-red color balance, values -100 <= x <= 100
; magenta-green in integers or floats
; yellow-blue
; Example: 100 0 0 turns the image reddish
; infile.png Input image file, must be a PNG
; outfile.png Output image file, will be a PNG
;
; Example Numbers
; 10 2 255 255 255 30 0 -30
; thin fuzzy white border on "sepia-toned" image
; 10 2 255 0 0 0 0 100
; thin fuzzy red border on image color-balanced to blue
;
; Differences:
; Unlike script-fu-old-photo, script-fu-dmm-old-photo does not
; "defocus" (gaussian RLE blur) or "mottle" (noisify and blur) the image.
; I prefer my old photographs to be crisp (as, aside from deliberate
; effects, old real photographs tend to be).
; This Script-Fu also differs from script-fu-old-photo in that it is
; designed to read and write files, making it suitable for batch processing
; from the bash command line.
;
; If you modify this Script-Fu, please change its name (use something
; other than "-dmm-", at least).
;
; This Script-Fu must be put in The GIMP's script directory
; (e.g., $HOME/.gimp-1.2/scripts).
; For command-line invocation, use the shell script script-fu-dmm-old-photo.sh
; For interactive invocation, run The GIMP and go to
; Xtns -> Script-Fu -> dmm
;
(define (script-fu-dmm-old-photo
border-width granularity border-red border-green border-blue
cyan-red magenta-green yellow-blue
infile outfile)
(let* ((image (car (file-png-load 1 infile infile)))
; get the "active drawable"
; Question: Is this the entire image when loading a PNG or JPG?
; If not, then the use of gimp-image-active-drawable
; is a bug, and something such as gimp-image-flatten
; should be used instead.
(drawable (car (gimp-image-active-drawable image)))
)
; Send all (gimp-message "foo") messages to stdout, not popup windows
; Useful for debugging in batch mode
(gimp-message-set-handler 1)
; NOTE: Do the sepia toning *before* the fuzzy border, so that
; the fuzzy border colors will be maintained.
; This is the opposite of what Gutteridge's script-fu-old-photo
; does, but it's ok there since he uses white (255 255 255)
; for the fuzzy border.
; The desaturation step to follow requires an RGB image.
; Here, detect any non-RGB or RGBA image and, if necessary,
; convert it to RGB. (Note: converting the image converts
; the drawable as well).
(if (> (car (gimp-drawable-type drawable)) 1)
(gimp-convert-rgb image)
()
)
; Use desaturation rather than conversion to grayscale because
; that's what script-fu-old-photo does.
(gimp-desaturate drawable)
; This step is used in script-fu-old-photo to fade the image.
; I omit it, because to me the past isn't faded, just monochrome ;-)
;(gimp-brightness-contrast drawable -20 -40)
(gimp-color-balance drawable
0 TRUE cyan-red magenta-green yellow-blue)
; transfer mode: 0=shadow, 1=midtones, 2=highlights
; preserve luminosity values at each pixel?
; cyan/red color balance (-100 <= cyan/red <= 100)
; magenta/green color balance
; yellow/blue color balance
; script-fu-old-photo uses 30 0 -30,
; which brings the red up a little bit
; and the yellow up (blue down) a little bit
; Eric R. Jeschke uses a quite different method
; in his "Sepia Toning" tutorial at gimp.org
; Note: His sepia RGB triplet is 162 138 101
; In percentages, that's 63 54 39
; see /usr/share/gimp/VERSION/scripts/fuzzyborder.scm for source
(script-fu-fuzzy-border image drawable
(list border-red border-green border-blue)
border-width TRUE granularity FALSE 100 FALSE TRUE )
; Fade-to color as RGB triplet. Change this to fade to
; differently colored backgrounds. This color does not
; affect the image color itself.
; approximate border width, in pixels
; I prefer a narrower border (10); this means that
; the granularity must go down (I like 2; 4 seems to
; work), or the image will have sharp cut-offs at
; the edges at some points.
; script-fu-old-photo default is 20 (w/granularity 8)
; blur border (Gauss RLE)?
; granularity (1 is low)
; script-fu-old-photo default is 8
; add shadow?
; shadow weight (percent)
; work on copy?
; flatten image?
;
; Must flatten the image, or the border changes above don't
; get saved to file below.
(set! drawable (car(gimp-image-flatten image)))
; Save as a PNG
(file-png-save 1 image drawable outfile outfile
1 0 0 0 0 0 0 )
; 1 Adam7 interlacing?
; 0 deflate compression factor (0-9)
; 0 Write bKGD chunk?
; 0 Write gAMMA chunk?
; 0 Write oFFs chunk?
; 0 Write tIME chunk? ?? backwards in DB Browser
; 0 Write pHYS chunk? ?? backwards in DB Browser
)
)
(script-fu-register ; I always forget these ...
"script-fu-dmm-old-photo" ; script name to register
"<Toolbox>/Xtns/Script-Fu/dmm/sfdmm-old-photo" ; where it goes
"fuzzy border, sepia tone; no defocus, mottle" ; script description
"David M. MacMillan" ; author
"Copyright 2004 by David M. MacMillan; GNU GPL" ; copyright
"2004-02-11" ; date
"RGB*, GRAY*" ; valid types of image
; default parameters
SF-VALUE "border-width" "10" ; fuzzy border
SF-VALUE "granularity" "2"
SF-VALUE "border-red" "255"
SF-VALUE "border-green" "255"
SF-VALUE "border-blue" "255"
SF-VALUE "cyan-red" "30" ; image color balance
SF-VALUE "magenta-green" "0" ; default is "sepia"
SF-VALUE "yellow-blue" "-30"
SF-FILENAME "infile" "infile.png"
SF-FILENAME "outfile" "outfile.png"
)
Shell script "script-fu-dmm-old-photo.sh" to invoke GIMP Script-Fu "script-fu-dmm-old-photo.scm":
# Invoke The GIMP with script-fu-dmm-old-photo # Warning: no input checking at all! # Note that the first three parameters (type: SF-VALUE) must NOT be quoted, # while the last two parameters (SF-FILENAME) must be quoted. gimp -c -i -d -b "(script-fu-dmm-old-photo $1 $2 $3 $4 $5 $6 $7 $8 \"$9.png\" \"$9-oldphoto.png\")" "(gimp-quit 0)"
Script-Fu: script-fu-dmm-old-photo.scm
Shell Script: script-fu-dmm-old-photo.sh
This is a shell (bash) script to invoke other shell scripts to in turn invoke GIMP Scripts-Fu to Resize (Scale), Rotate, and Convert to JPG all PNG images in a directory. The ls command could be changed to match different sets of files. If the source images are Indexed, you'll have to add a conversion to Grayscale (see above) or RGB (not in the Scripts-Fu above) before converting to JPG. The GIMPSCRIPTSH variable must be modified to suit local conditions.
GIMPSCRIPTSH=/path/to/script-fu/shell/scripts for f in `ls *.png` do b=`basename $f ".png"` echo "Scaling $b.png to 1000 pixels wide" $GIMPSCRIPTSH/dmmScalePNG.sh 1000 $b echo "Rotating $b-scale1000.png 90 degrees clockwise" $GIMPSCRIPTSH/dmmRotatePNG.sh 90 $b-scale1000 rm -f $b-scale1000.png echo "Converting $b-scale1000-rot90.png to JPG" $GIMPSCRIPTSH/dmmConvertPNGtoJPG.sh $b-scale1000-rot90 done
Shell Script: transform-example.sh
Copyright © 2002, 2004 by David M. MacMillan.
Permission is granted to copy, distribute and/or modify copyrighted portions of this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the file entitled "GNU Free Documentation License."
The Script-Fu scripts and shell scripts here are also present, in the original distribution, as files and are released, as indicated in those files, under the GNU General Public License Version 2 or (at your option) any later version. A copy of this license is included in the file entitled "GNU General Public License".
Note: Those portions of this document which are in the public domain, if any, may be copied freely. The distribution of these public domain portions is subject to all of the disclaimers of warranty and liability noted herein.
This work is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Free Documentation License for more details.
You should have received copies of the GNU Free Documentation License and the GNU General Public License along with this work; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
This work is distributed "as-is," without any warranty of any kind, expressed or implied; without even the implied warranty of merchantability or fitness for a particular purpose.
In no event will the author(s), editor(s), or publisher(s) of this work be liable to you or to any other party for damages, including but not limited to any general, special, incidental or consequential damages arising out of your use of or inability to use this work or the information contained in it, even if you have been advised of the possibility of such damages.
In no event will the author(s), editor(s), or publisher(s) of this work be liable to you or to any other party for any injury, death, disfigurement, or other personal damage arising out of your use of or inability to use this work or the information contained in it, even if you have been advised of the possibility of such injury, death, disfigurement, or other personal damage.
lemur.com is a service mark of
David M. MacMillan
and Rollande Krandall.
Other trademark
recognition.
Presented originally by lemur.com.SM