; CREATE-ROUND_CORNER ; Gimp-Script for being executed via shell ; ; written in Nov 2008 by Markus Schmidt (boomshop.net) ; ; This script creates a set of images to build a transparent box with round corners ; ; To do this call it from a script-fu-terminal with specific arguments: ; ; script-fu-create-round-corner 1 $size $alpha $R $G $B $path ; ; $size = size of the corners in pixel (int) ; $alpha = amount of opacity, 0 = invisible - 100 = no transparency (int) ; $R, $G, $B = red, green and blue amount inside a range of 0-255 (int) ; $path = the directory to output to (must exist and contain a trailing slash!) (string) ; ; Shell-command-line: ; ; gimp -i -d -f -s -c -b "(script-fu-create-round-corner 1 12 75 0 0 0 \"blinder/black/75/12/\")" ; ; Shell-script-example: ; ; #!/bin/bash ; $size=12 ; $alpha=75 ; $R=0 ; $G=0 ; $B=0 ; gimp -i -d -f -s -c -b "(script-fu-create-round-corner 1 $size $alpha $R $G $B \"blinder/black/75/12/\")" ; ; both of the above would create the following files: ; ; blinder/black/75/12/tl.png < Top-left black corner at 12 px and 75% opacity ; blinder/black/75/12/tr.png < Top-right black corner at 12 px and 75% opacity ; blinder/black/75/12/c.png < Square box at 12 px and 75% opacity ; blinder/black/75/12/bl.png < Bottom-left black corner at 12 px and 75% opacity ; blinder/black/75/12/br.png < Bottom-right black corner at 12 px and 75% opacity ; ; full bash-script to create subdirs and files from 3 to 50px size and ; 5-100% opacity (5% steps) in black: ; ;#!/bin/bash ;mkdir "blinder" ;mkdir "blinder/black" ;i=1 ;while [ $i -le 20 ] ; do ; let alpha=$i*5 ; mkdir "blinder/black/$alpha" ; j=3 ; while [ $j -le 50 ] ; do ; mkdir "blinder/black/$alpha/$j" ; gimp -i -d -f -s -c -b "(script-fu-create-round-corner 1 $j $alpha 0 0 0 \"blinder/black/$alpha/$j/\")" ; let j=$j+1 ; done ; let i=$i+1 ;done (define (script-fu-create-round-corner inQuit inSize inAlpha inR inG inB outPath ) (let* ( ;all possible objects an variables have to be set here (myImage (car (gimp-image-new inSize inSize 0))) (myLayer (car (gimp-layer-new myImage inSize inSize 0 "myLayer" inAlpha 0))) (oldForeground (car (gimp-palette-get-foreground))) (oldBackground (car (gimp-palette-get-background))) (myColor (list inR inG inB)) (outImage "") (outPath2 "") ) ; ####### PRESETS ;add alpha-channel to the original (gimp-layer-add-alpha myLayer) (gimp-image-add-layer myImage myLayer 0) ;select color (gimp-palette-set-foreground myColor) (define i 0) (while (< i 5) (set! outPath2 outPath) (gimp-selection-all myImage) (gimp-edit-clear myLayer) (if (= i 0) (set! outImage (string-append outPath2 "c.png")) ) (if (> i 0) (gimp-selection-none myImage) ) ;select Corner (if (= i 1) (begin (gimp-ellipse-select myImage 0 0 (* inSize 2) (* inSize 2) CHANNEL-OP-ADD TRUE 0 0) (set! outImage (string-append outPath2 "tl.png")) ) ) (if (= i 2) (begin (gimp-ellipse-select myImage (* -1 inSize) 0 (* inSize 2) (* inSize 2) CHANNEL-OP-ADD TRUE 0 0) (set! outImage (string-append outPath2 "tr.png")) ) ) (if (= i 3) (begin (gimp-ellipse-select myImage (* -1 inSize) (* -1 inSize) (* inSize 2) (* inSize 2) CHANNEL-OP-ADD TRUE 0 0) (set! outImage (string-append outPath2 "br.png")) ) ) (if (= i 4) (begin (gimp-ellipse-select myImage 0 (* -1 inSize) (* inSize 2) (* inSize 2) CHANNEL-OP-ADD TRUE 0 0) (set! outImage (string-append outPath2 "bl.png")) ) ) (gimp-edit-fill myLayer 0) (gimp-layer-set-opacity myLayer inAlpha) ; ####### RENDER TO FILE (set! myLayer (car (gimp-image-merge-visible-layers myImage 1))) (file-png-save RUN-NONINTERACTIVE myImage myLayer outImage outImage 0 9 0 0 0 0 0) (set! i (+ i 1)) ) ; ####### CLEANUP (gimp-palette-set-foreground oldForeground) (gimp-palette-set-background oldBackground) (if (> inQuit 0) (gimp-quit 1)) ) )