; (define (script-fu-test textStuff fontType fontColor bgColor) ; Begin Script (let* ( ; Declare W/H vars & assign dummy val (imgWidth 1) (imgHeight 1) ; Declare and create the new image (img (car (gimp-image-new imgWidth imgHeight RGB))) ; Declare/create layers in the image: (bgLayer (car (gimp-layer-new img imgWidth imgHeight RGB_IMAGE "Background" 100 NORMAL ) ) ) (baseLayer (car (gimp-layer-new img imgWidth imgHeight RGB_IMAGE "Text Layer" 100 NORMAL) ) ) ; Keep the background colors (old-fg (car (gimp-palette-get-foreground))) (old-bg (car (gimp-palette-get-background))) ) ; (End of "(let* ... (" ) ; Disable undo recording (gimp-image-undo-disable img) ; Add the layers to the image (gimp-image-add-layer img bgLayer 0) (gimp-image-add-layer img baseLayer 0) ; Set the fground and bground colors (gimp-palette-set-background bgColor) (gimp-palette-set-foreground fontColor) ; Clear the background layer (gimp-edit-clear bgLayer) ; Add alpha and clear the text layer (gimp-layer-add-alpha baseLayer) (gimp-edit-clear baseLayer) ; Create the new text layer (let* ( (floatText (car (gimp-text-fontname img baseLayer 0 0 textStuff 5 TRUE 24 PIXELS fontType)) ) ) ; (End of nested "(let * ... (" ) ; Resize the Image to proper size (set! imgWidth (car (gimp-drawable-width floatText))) (set! imgHeight (car (gimp-drawable-height floatText))) (gimp-image-resize img imgWidth imgHeight 0 0) (gimp-layer-resize bgLayer imgWidth imgHeight 0 0) (gimp-layer-resize baseLayer imgWidth imgHeight 0 0) (gimp-floating-sel-anchor floatText) ) ; (End of nested "(let *" ) ; Flatten the Image (set! bgLayer (car (gimp-image-flatten img))) ; Autocrop (plug-in-autocrop FALSE img bgLayer) ; Clear the dirty count. (gimp-image-clean-all img) ; Display the new image (gimp-display-new img) ; Add undo support again (gimp-image-undo-enable img) ; Reset the colors (gimp-palette-set-foreground old-fg) (gimp-palette-set-background old-bg) ) ; (End of outer "(let *" ) ) ; Register script with the Gimp (script-fu-register "script-fu-test" "/Xtns/Script-Fu/Misc/Test" ; Menu location "SCRIPT NAME" "AUTHOR" "COPYRIGHT" "MODIFY DATE" "" ; Image types SF-STRING "Text" "Hello World" SF-FONT "Font" "-freefont-agate-normal-r-normal-*-24-*-*-*-p-*-*-*" SF-COLOR "Font Color" '(0 0 100) SF-COLOR "Background Color" '(222 234 234) )