;ROUND-BORDER-MIRROR ;Gimp-Script for being executed via shell ; ;written in Jan 2008 by Markus Schmidt (boomshop.net) ; ;This script rounds the edges of a given image to a given radius ;puts a border of given color, width, radius and alpha-mask around ;and mirrors the result to a given scale, visible viewport and opacity. ;this version can also draw a shadow instead of the mirror and is able ;to use a mask for the image after the border ; ;EXAMPLE SHELL: ;gimp --console-messages --batch-interpreter plug-in-script-fu-eval --no-interface --batch "(script-fu-round-border-mirror 0 \"/home/markus/Desktop/test.jpg\" \"/home/markus/Desktop/test2.jpg\" 0 0.9 0.5 0.5 50 2 10 5 5 5 255 255 255 180 50 0 50 1 0.5 0.3 1 \"\" 255 0 255 20 1 0 0 0 \"\" \"\" 6 0 20 1)" ; ;EXAMPLE Script-FU-Terminal in GIMP: ;(script-fu-round-border-mirror 0 "/home/markus/Desktop/test.jpg" "/home/markus/Desktop/test2.jpg" 0 0.9 0.5 0.5 50 2 10 5 5 5 255 255 255 180 50 0 50 1 0.5 0.3 1 "" 255 0 255 20 1 0 0 0 "" "" 6 0 20 1) ; ;Generates an image with a 5px wide border an 10px rounded edges. ;The border is a fading-out white one with 5px rounded edges. ;The mirror is scaled down to 50% height of the original image and is visible only half of the scaled height. ;The original image seems to float 2px above the ground ;The background is filled with pink. ; ;KNOWN BUGS: ;"inexpected" values may produce weird output or may crash the script. For example: ;A thumbnail with 100px height can't have borders of 20px and a bottom-border of 90px (results in 110px overall border-height) ;Radiants with a greater height than 1/2 of the thumbnailsize are not implemented (should be rounder than round?) ; ; ;OPTIONS: ; inQuit quits gimp after the process; values 0 or 1 ; inImage path of the original; /path/to/an/image.png ; outImage path of the generated picture: /path/to/generated.png ; outAlpha output rendered with alpha-channel or not; 0 generates JPG-file, 1 generates PNG-file ; outCompression compression-level of the output, optically only affecting JPG-images; JPG: values 0.0 - 1.0 PNG: values 1-9 ; inMirrorScale height of the mirror; values between 0.0 an 1.0 (higher values possible but not satisfying) ; inMirrorShow visible part of the scaled mirror; values between 0.0 and 1.0 ; inMirrorAlpha visibility of the mirror; values between 0 and 100 ; inMirrorPadding the padding between the original and the mirror; apprehanded as the distance from the "floor" ; inRadius radius of the rounden corners of the overall image; values between 0 and half of width/height ; inBorder width of the border ; inLowerBorder width of the border at the bottom of the image (generates a "polaroid-like-style") ; inBorderRadius radius of the inner border; best values are inRadius - inBorder; other values possible (generates special styles) ; inBorderR amount of red color for the border; values between 0 and 255 ; inBorderG amount of green color for the border; values between 0 and 255 ; inBorderB amount of blue color for the border; values between 0 and 255 ; inBorderTopAlpha opacity of the top border; values between 0 and 255; 0 means invisible ; inBorderBottomAlpha opacity of the bottom border; values between 0 and 255; 0 means invisible ; inBorderBlendMode how to blend the border in the picture; values 0 - 22 (more info: http://hans.breuer.org/gimp/pdb/layer.html#gimp_layer_new ; inGlassAlpha opacity of the glassy effect; values between 0 and 100; 0 means invisible ; inGlassPadding padding of the glass-effect to inner frameborder; ; inGlassHeight cut off the glass-layer at inner-dimensions * inGlassHeight; values between 0 and 1 ; inGlassEdge give the glass-fx a hard edge at the bottom; 0.0 shows no edge while 1.0 results in a hard edge; values between 0 and 1 ; inBackground toggles rendering of background-color; 0 or 1 ; inBackgroundImage path to a background-image; /path/to/background.img; empty for no image ; inBackgroundR amount of red color for the border, only used, if inBackground=1; values between 0 and 255 ; inBackgroundG amount of green color for the border, only used, if inBackground=1; values between 0 and 255 ; inBackgroundB amount of blue color for the border, only used, if inBackground=1; values between 0 and 255 ; inSharpen sharpens the original picture at X percent; values between 0 and 100 ; inCurve perform a kind of white-balance or contrast-stretch to the image; 0 or 1 ; inShadow draws a shadow instead of a mirror behind the image; a value of 0 turns on mirror; values above 0 turn mirror off and enable shadow; value for radius of shadow ; inShadowAmount opacity of the shadow; only used if inShadow > 0; values between 0 and 100 ; inShadowOffset replace the mirror in bottom-direction; pixel ; inMaskImage path to a b/w image that acts as a mask for the original; white parts ill be visible,black parts will be ripped from original; mask is resized first to fit original image sizes; applied after the border ; inOverlayImage path to a picture added on top of all layers (PNG with alpha makes sense); picture will be stretched to resulting dimensions (including shadow or mirror) unless you set inOverlayPosition to anything else than "" ; inOverlayPosition position of overlay-image in the new image; if set to 0 overlay-image is stretched to resulting dimensions; values: 1=north, 2=northeast, 3=east, 4=southeast, 5=south, 6=southwest, 7=west, 8=northwest, 9=center ; inOverlayBlendMode how to blend the overlay in the picture; values 0 - 22 (more info: http://hans.breuer.org/gimp/pdb/layer.html#gimp_layer_new ; inBevel amount of beveling the thumb; top will be lightened, bottom goes darker; 0 - 100 percent ; inBevelPadding padding of bevel-effect to inner border in pixels; values below 0 are possible, if you have a border; (define (script-fu-round-border-mirror inQuit inImage outImage outAlpha outCompression inMirrorScale inMirrorShow inMirrorAlpha inMirrorPadding inRadius inBorder inLowerBorder inBorderRadius inBorderR inBorderG inBorderB inBorderTopAlpha inBorderBottomAlpha inBorderBlendMode inGlassAlpha inGlassPadding inGlassHeight inGlassEdge inBackground inBackgroundImage inBackgroundR inBackgroundG inBackgroundB inSharpen inCurve inShadow inShadowAmount inShadowOffset inMaskImage inOverlayImage inOverlayPosition inOverlayBlendMode inBevel inBevelPadding ) (let* ( ;all possible objects an variables have to be set here (myImage (car (gimp-file-load RUN-NONINTERACTIVE inImage inImage))) (myLayer (car (gimp-image-get-active-layer myImage))) (myDraw (car (gimp-image-get-active-drawable myImage))) (myWidth (car (gimp-image-width myImage))) (myHeight (car (gimp-image-height myImage))) (myNewWidth) (myNewHeight) (myDiam (* 2 inRadius)) (myDiamBorder (* 2 inBorderRadius)) (myBorderColor (list inBorderR inBorderG inBorderB)) (myBorder) (myBorderGrad) (myBorderGradStart (list inBorderTopAlpha inBorderTopAlpha inBorderTopAlpha)) (myBorderGradEnd (list inBorderBottomAlpha inBorderBottomAlpha inBorderBottomAlpha)) (myMirror) (myMirrorGrad) (myMirrorGradStart '(255 255 255)) (myMirrorGradEnd '(0 0 0)) (myGlass) (myGlassGrad) (myGlassGradStart '(255 255 255)) (myGlassGradEnd '(0 0 0)) (myDiamGlass (* (- inBorderRadius inGlassPadding) 2)) (myRadiusGlass (/ myDiamGlass 2)) (myGlassHeight (* (- myHeight (* 2 inGlassPadding) inBorder inLowerBorder) inGlassHeight)) (myGlassGradHeight (* myGlassHeight (+ inGlassEdge 1))) (myBackground) (myBackgroundImage) (myBackgroundImageFile) (myMask) (myMaskFloat) (myMaskImage) (myShadow) (myBevel) (myBevelGradStart '(255 255 255)) (myBevelGradEnd '(0 0 0)) (myDiamBevel (* (- inBorderRadius inBevelPadding) 2)) (myRadiusBevel (/ myDiamBevel 2)) (myBevelHeight (- myHeight (* 2 inBevelPadding) inBorder inLowerBorder)) (myOverlay) (myOverlayImage) (myOverlayImageFile) (myOverlayWidth) (myOverlayHeight) (myBGColor (list inBackgroundR inBackgroundG inBackgroundB)) (oldForeground (car (gimp-palette-get-foreground))) (oldBackground (car (gimp-palette-get-background))) ) ; ####### PRESETS ; new width and new hight according to shadow or mirror (if (= inShadow 0) (begin (set! myNewHeight (+ (* (* inMirrorScale myHeight) inMirrorShow) inMirrorPadding myHeight)) (set! myNewWidth myWidth) ) (begin (set! myNewHeight (+ (* inShadow 2) myHeight inShadowOffset)) (set! myNewWidth (+ (* inShadow 2) myWidth)) ) ) ;add alpha-channel to the original (gimp-layer-add-alpha myLayer) ;set the foreground-color as border-color (if (< myDiamGlass 0) (set! myDiamGlass 0) ()) (if (< myRadiusGlass 0) (set! myRadiusGlass 0) ()) (if (> myDiamGlass myGlassHeight) (set! myDiamGlass myGlassHeight) ()) (if (> myDiamGlass myGlassHeight) (set! myDiamGlass myGlassHeight) ()) ; ####### SHARPEN (if (> inSharpen 0) (plug-in-sharpen RUN-NONINTERACTIVE myImage myLayer inSharpen) ()) ; ####### CURVE (if (> inCurve 0) (plug-in-c-astretch RUN-NONINTERACTIVE myImage myLayer) ()) ; ####### BEVEL (if (> inBevel 0) (begin ;new layer for the bevel-fx (set! myBevel (car (gimp-layer-new myImage myWidth myHeight 0 "myBevel" inBevel 18))) (gimp-layer-add-alpha myBevel) (gimp-image-add-layer myImage myBevel -1) ;set the colors for the gradient inside the mask (gimp-palette-set-foreground myBevelGradStart) (gimp-palette-set-background myBevelGradEnd) ;draw the gradient to the bevel-layer (gimp-edit-blend myBevel FG-BG-RGB NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 0 0 FALSE (- inBorder inBevelPadding) (- inBorder inBevelPadding) (- inBorder inBevelPadding) (+ myBevelHeight inBorder inBevelPadding)) ;select all (gimp-selection-all myImage) ;deselect the inside of the glass for non-removal (gimp-ellipse-select myImage (+ inBorder inBevelPadding) (+ inBorder inBevelPadding) myDiamBevel myDiamBevel CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-ellipse-select myImage (- myWidth myDiamBevel inBorder inBevelPadding) (+ inBorder inBevelPadding) myDiamBevel myDiamBevel CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-ellipse-select myImage (+ inBorder inBevelPadding) (- (+ myBevelHeight inBorder inBevelPadding) myDiamBevel) myDiamBevel myDiamBevel CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-ellipse-select myImage (- myWidth myDiamBevel inBorder inBevelPadding) (- (+ myBevelHeight inBorder inBevelPadding) myDiamBevel) myDiamBevel myDiamBevel CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-rect-select myImage (+ inBorder inBevelPadding) (+ inBorder myRadiusBevel inBevelPadding) (- myWidth inBorder inBorder (* 2 inBevelPadding)) (- myBevelHeight myDiamBevel) CHANNEL-OP-SUBTRACT 0 0) (gimp-rect-select myImage (+ inBorder myRadiusBevel inBevelPadding) (+ inBorder inBevelPadding) (- myWidth inBorder inBorder (* 2 inBevelPadding) myDiamBevel) myBevelHeight CHANNEL-OP-SUBTRACT 0 0) ;delete selection (gimp-edit-clear myBevel) ;remove selection (gimp-selection-none myImage) ;merge the image-layer with the bevel-layer (set! myLayer (car (gimp-image-merge-visible-layers myImage 1))) ) ) ; ####### ROUND CORNERS ;select the corners (if (> inRadius 0) (begin (gimp-selection-none myImage) (gimp-rect-select myImage 0 0 inRadius inRadius CHANNEL-OP-ADD 0 0) (gimp-ellipse-select myImage 0 0 myDiam myDiam CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-rect-select myImage (- myWidth inRadius) 0 inRadius inRadius CHANNEL-OP-ADD 0 0) (gimp-ellipse-select myImage (- myWidth myDiam) 0 myDiam myDiam CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-rect-select myImage 0 (- myHeight inRadius) inRadius inRadius CHANNEL-OP-ADD 0 0) (gimp-ellipse-select myImage 0 (- myHeight myDiam) myDiam myDiam CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-rect-select myImage (- myWidth inRadius) (- myHeight inRadius) inRadius inRadius CHANNEL-OP-ADD 0 0) (gimp-ellipse-select myImage (- myWidth myDiam) (- myHeight myDiam) myDiam myDiam CHANNEL-OP-SUBTRACT TRUE 0 0) ;delete selection (gimp-edit-clear myLayer) ) ) ; ####### BORDER ;new layer for the border (set! myBorder (car (gimp-layer-new myImage myWidth myHeight 0 "myBorder" 100 inBorderBlendMode))) (gimp-layer-add-alpha myBorder) (gimp-image-add-layer myImage myBorder 0) ;set the foreground-color as border-color (gimp-context-set-foreground myBorderColor) ;fill with border-layer foreground-color (gimp-drawable-fill myBorder 0) ;delete the edges with selection from above (if (> inRadius 0) (gimp-edit-clear myBorder) ) ;remove selection (gimp-selection-none myImage) ;select inner part of the border-layer (gimp-ellipse-select myImage inBorder inBorder myDiamBorder myDiamBorder CHANNEL-OP-ADD TRUE 0 0) (gimp-ellipse-select myImage (- myWidth myDiamBorder inBorder) inBorder myDiamBorder myDiamBorder CHANNEL-OP-ADD TRUE 0 0) (gimp-ellipse-select myImage inBorder (- myHeight myDiamBorder inLowerBorder) myDiamBorder myDiamBorder CHANNEL-OP-ADD TRUE 0 0) (gimp-ellipse-select myImage (- myWidth myDiamBorder inBorder) (- myHeight myDiamBorder inLowerBorder) myDiamBorder myDiamBorder CHANNEL-OP-ADD TRUE 0 0) (gimp-rect-select myImage inBorder (+ inBorder inBorderRadius) (- myWidth inBorder inBorder) (- myHeight inBorder inLowerBorder myDiamBorder) CHANNEL-OP-ADD 0 0) (gimp-rect-select myImage (+ inBorder inBorderRadius) inBorder (- myWidth inBorder inBorder myDiamBorder) (- myHeight inBorder inLowerBorder) CHANNEL-OP-ADD 0 0) ;delete selection (gimp-edit-clear myBorder) ;remove selection (gimp-selection-none myImage) ;add a mask to the border-layer (set! myBorderGrad (car (gimp-layer-create-mask myBorder 0))) (gimp-layer-add-mask myBorder myBorderGrad) ;set the colors for the gradient inside the mask (gimp-palette-set-foreground myBorderGradStart) (gimp-palette-set-background myBorderGradEnd) ;draw the gradient inside the mask (gimp-edit-blend myBorderGrad FG-BG-RGB 0 GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 0 0 FALSE 0 0 0 myHeight) ;add the mask permanently to the border-layer by removing it (gimp-layer-remove-mask myBorder 0) ;merge the image-layer with the border-layer (set! myLayer (car (gimp-image-merge-visible-layers myImage 1))) ; ####### GLASS (if (> inGlassAlpha 0) (begin ;new layer for the glass-fx (set! myGlass (car (gimp-layer-new myImage myWidth myHeight 0 "myGlass" inGlassAlpha 4))) (gimp-layer-add-alpha myGlass) (gimp-image-add-layer myImage myGlass -1) ;set the colors for the gradient inside the mask (gimp-palette-set-foreground myGlassGradStart) (gimp-palette-set-background myGlassGradEnd) ;draw the gradient to the glass-layer (gimp-edit-blend myGlass FG-BG-RGB NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 0 0 FALSE (+ inBorder inGlassPadding) (+ inBorder inGlassPadding) (+ inBorder inGlassPadding) (+ myGlassGradHeight inBorder inGlassPadding)) ;select all (gimp-selection-all myImage) ;deselect the inside of the glass for non-removal (gimp-ellipse-select myImage (+ inBorder inGlassPadding) (+ inBorder inGlassPadding) myDiamGlass myDiamGlass CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-ellipse-select myImage (- myWidth myDiamGlass inBorder inGlassPadding) (+ inBorder inGlassPadding) myDiamGlass myDiamGlass CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-ellipse-select myImage (+ inBorder inGlassPadding) (- (+ myGlassHeight inBorder inGlassPadding) myDiamGlass) myDiamGlass myDiamGlass CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-ellipse-select myImage (- myWidth myDiamGlass inBorder inGlassPadding) (- (+ myGlassHeight inBorder inGlassPadding) myDiamGlass) myDiamGlass myDiamGlass CHANNEL-OP-SUBTRACT TRUE 0 0) (gimp-rect-select myImage (+ inBorder inGlassPadding) (+ inBorder myRadiusGlass inGlassPadding) (- myWidth inBorder inBorder (* 2 inGlassPadding)) (- myGlassHeight myDiamGlass) CHANNEL-OP-SUBTRACT 0 0) (gimp-rect-select myImage (+ inBorder myRadiusGlass inGlassPadding) (+ inBorder inGlassPadding) (- myWidth inBorder inBorder (* 2 inGlassPadding) myDiamGlass) myGlassHeight CHANNEL-OP-SUBTRACT 0 0) ;delete selection (gimp-edit-clear myGlass) ;remove selection (gimp-selection-none myImage) ;merge the image-layer with the glass-layer (set! myLayer (car (gimp-image-merge-visible-layers myImage 1))) ) ) ; ####### MASK (if (> (string-length inMaskImage) 0) (begin ;new layer for the mask-image (set! myMaskImage (car (gimp-file-load RUN-NONINTERACTIVE inMaskImage inMaskImage))) (set! myMask (car (gimp-image-get-active-drawable myMaskImage))) (gimp-image-scale myMaskImage myWidth myHeight) (gimp-edit-copy myMask) (set! myMask (car (gimp-layer-create-mask myLayer 0))) (gimp-layer-add-mask myLayer myMask) (set! myMaskFloat (car (gimp-edit-paste myMask 0))) (gimp-floating-sel-anchor myMaskFloat) (gimp-layer-remove-mask myLayer 0) ) ) ; ####### OVERLAY (if (> (string-length inOverlayImage) 0) (begin ;new layer for the overlay-image (set! myOverlayImageFile (car (gimp-file-load RUN-NONINTERACTIVE inOverlayImage inOverlayImage))) (set! myOverlayWidth (car (gimp-image-width myOverlayImageFile))) (set! myOverlayHeight (car (gimp-image-height myOverlayImageFile))) (set! myDraw (car (gimp-image-get-active-drawable myOverlayImageFile))) (gimp-edit-copy myDraw) (set! myOverlayImage (car (gimp-layer-new-from-drawable myDraw myImage))) (gimp-image-add-layer myImage myOverlayImage -1) (if (> inOverlayPosition 0) (begin (if (= inOverlayPosition 1) (gimp-layer-translate myOverlayImage (- (/ myWidth 2) (/ myOverlayWidth 2)) 0) ) (if (= inOverlayPosition 2) (gimp-layer-translate myOverlayImage (- myWidth myOverlayWidth) 0) ) (if (= inOverlayPosition 3) (gimp-layer-translate myOverlayImage (- myWidth myOverlayWidth) (- (/ myHeight 2) (/ myOverlayHeight 2))) ) (if (= inOverlayPosition 4) (gimp-layer-translate myOverlayImage (- myWidth myOverlayWidth) (- myHeight myOverlayHeight)) ) (if (= inOverlayPosition 5) (gimp-layer-translate myOverlayImage (- (/ myWidth 2) (/ myOverlayWidth 2)) (- myHeight myOverlayHeight)) ) (if (= inOverlayPosition 6) (gimp-layer-translate myOverlayImage 0 (- myHeight myOverlayHeight)) ) (if (= inOverlayPosition 7) (gimp-layer-translate myOverlayImage 0 (- (/ myHeight 2) (/ myOverlayHeight 2))) ) (if (= inOverlayPosition 8) (gimp-layer-translate myOverlayImage 0 0) ) (if (= inOverlayPosition 9) (gimp-layer-translate myOverlayImage (- (/ myWidth 2) (/ myOverlayWidth 2)) (- (/ myHeight 2) (/ myOverlayHeight 2))) ) ) (begin (gimp-layer-scale myOverlayImage myNewWidth myNewHeight 0) ) ) (gimp-layer-set-mode myOverlayImage inOverlayBlendMode) (set! myLayer (car (gimp-image-merge-visible-layers myImage 1))) ) ) ; ####### RESIZE ;resize the canvas (gimp-image-resize myImage myNewWidth myNewHeight inShadow inShadow) (if (> inShadow 0) (begin ; ####### SHADOW ;copy layer (set! myShadow (car (gimp-layer-copy myLayer 1))) (gimp-image-add-layer myImage myShadow -1) (gimp-layer-resize-to-image-size myShadow) ;lower layer (gimp-image-lower-layer myImage myShadow) ;select alpha (gimp-selection-layer-alpha myShadow) ;set the color to fill with (gimp-palette-set-foreground '(0 0 0)) ;fill layer (gimp-edit-fill myShadow 0) ;blur layer (gimp-selection-all myImage) (plug-in-gauss RUN-NONINTERACTIVE myImage myShadow inShadow inShadow 0) ;move layer (gimp-layer-translate myShadow 0 inShadowOffset) ;opacity (gimp-layer-set-opacity myShadow inShadowAmount) (set! myLayer (car (gimp-image-merge-visible-layers myImage 1))) ) (begin ; ####### MIRROR ;copy the original image to new mirror-layer (set! myMirror (car (gimp-layer-copy myLayer 1))) (gimp-image-add-layer myImage myMirror -1) ;transform the mirror-layer (gimp-drawable-transform-flip-simple myMirror 1 0 (/ myHeight 2) 1) ;add a mask to the mirror-layer (set! myMirrorGrad (car (gimp-layer-create-mask myMirror 0))) (gimp-layer-add-mask myMirror myMirrorGrad) ;set the colors for the gradient inside the mask (gimp-palette-set-foreground myMirrorGradStart) (gimp-palette-set-background myMirrorGradEnd) ;draw the gradient inside the mask (gimp-edit-blend myMirrorGrad FG-BG-RGB NORMAL-MODE GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE FALSE 0 0 FALSE 0 0 0 (* myHeight inMirrorShow)) ;add the mask permanently to the mirror-layer by removing it (gimp-layer-remove-mask myMirror 0) ;scale the mirror-layer (gimp-layer-scale myMirror myWidth (* myHeight inMirrorScale) 0) ;move the mirror-layer to desired position (gimp-layer-set-offsets myMirror 0 (+ myHeight inMirrorPadding)) ;add given alpha to the mirror-layer (gimp-layer-set-opacity myMirror inMirrorAlpha) (set! myLayer (car (gimp-image-merge-visible-layers myImage 1))) ) ) ; ####### BACKGROUND (if (= inBackground 1) (begin ;set the foreground-color as background-color (gimp-context-set-foreground myBGColor) ;new layer for the background (set! myBackground (car (gimp-layer-new myImage myNewWidth myNewHeight 0 "myBackground" 100 0))) (gimp-image-add-layer myImage myBackground 2) ;fill background (gimp-selection-all myImage) (gimp-drawable-fill myBackground 0) ) ) (if (> (string-length inBackgroundImage) 0) (begin ;new layer for the background-image (set! myBackgroundImageFile (car (gimp-file-load RUN-NONINTERACTIVE inBackgroundImage inBackgroundImage))) (set! myDraw (car (gimp-image-get-active-drawable myBackgroundImageFile))) (gimp-edit-copy myDraw) (set! myBackgroundImage (car (gimp-layer-new-from-drawable myDraw myImage))) (gimp-image-add-layer myImage myBackgroundImage 1) (gimp-layer-scale myBackgroundImage myNewWidth myNewHeight 0) ) ) ; ####### RENDER TO FILE (set! myDraw (car (gimp-image-merge-visible-layers myImage 1))) ;(gimp-file-save RUN-NONINTERACTIVE myImage myDraw outImage outImage) (if (= outAlpha 1) (begin (file-png-save RUN-NONINTERACTIVE myImage myDraw outImage outImage 0 outCompression 0 0 0 0 0) ) ) (if (= outAlpha 0) (file-jpeg-save RUN-NONINTERACTIVE myImage myDraw outImage outImage outCompression 0.0 0 0 "Rendered by the GIMP" 0 0 0 0) ) (if (= outAlpha 2) (begin (gimp-image-convert-indexed myImage 2 0 255 1 0 "") (file-gif-save RUN-NONINTERACTIVE myImage myDraw outImage outImage 0 0 0 0) ) ) ; ####### CLEANUP (gimp-palette-set-foreground oldForeground) (gimp-palette-set-background oldBackground) (if (> inQuit 0) (gimp-quit 1)) ) )