(let*
; define variables in here
(
; runmode (0 = interactive, 1 = noninteractive)
(runmode 1)
; load the image
(image (car (gimp-file-load runmode "test.png"
"test.png")))
; get its drawable
(drawable (car (gimp-image-get-active-drawable 1)))
; dimensions
(width (car (gimp-drawable-width drawable)))
(height (car (gimp-drawable-height drawable)))
;
(maxdimension 0)
(borderpixels 0)
(megapixels 0)
(targetmegapixels 0.75)
(ratio 0)
)
; erase the middle black bar on split-screen ParaView plots
; you can take this out if it interferes
(gimp-edit-bucket-fill drawable 1 0 100 0 FALSE (round (/ (- width 1) 2)) 0)
; autocrop
(plug-in-autocrop runmode image drawable)
; get current dimensions
(set! width (car (gimp-drawable-width drawable)))
(set! height (car (gimp-drawable-height drawable)))
; add a border
(set! maxdimension (max width height))
(set! borderpixels (max 1 (round (* maxdimension 0.01))))
(set! width (+ width borderpixels borderpixels))
(set! height (+ height borderpixels borderpixels))
(gimp-image-resize image width height borderpixels borderpixels)
; resize the layer to match the new image size
(gimp-layer-resize-to-image-size (car (gimp-image-get-active-layer image)))
; get current dimensions and megapixels
(set! megapixels (/ (* width height) 1000000))
; find scaling factor
(set! ratio (sqrt (/ targetmegapixels megapixels)))
; scale the image (using cubic interpolation)
(set! width (round (* width ratio)))
(set! height (round (* height ratio)))
(gimp-image-scale-full image width height 2)
; save it
(gimp-file-save runmode image drawable
"gimpout.png"
"gimpout.png")
; delete it from memory
(gimp-image-delete image)
)
which works if I enter this into the script-fu console. I want to run this in Linux using something like
gimp -s -i -d -b < scriptfile
so it runs the script directly from the command line. Is there any way to accomplish this? I know you can do things like
gimp -s -i -d -b '(gimp-file-load 1 "test.png" "test.png"' 'othercommands...' '(gimp-quit 0)'
but this doesn't seem to be working for a larger command like this embedded in a (let* ) block. I don't want to register the script, which would force me to register it on every computer I use.
Thanks in advance!

Help










