;; ;; Freely distributed ;; ;; Version 1.0 by Pavel Antokolsky aka Zigmar (antokol@isdn.net.il) ;; ;; Version 1.1 Fufie (fufie@boblycat.org) ;; ;; - Improved error-checking and undo works ;; - Addded support for copyright-notice ;; - Moved script to S-Fu/Decor ;; ;; Version 1.2 Fufie (fufie@boblycat.org) ;; ;; - Added blur-effect on copyright-notice ;; as suggested by Eugene (define (script-fu-border-with-copyright aimg adraw ib-width ib-colour ob-width ob-colour text font-name font-size font-colour blur-text work-on-copy flatten-image) (let* ((type (car (gimp-drawable-type-with-alpha adraw))) (img (if (= work-on-copy TRUE) (car (gimp-image-duplicate aimg)) aimg)) (old-width (car (gimp-image-width img))) (old-height (car (gimp-image-height img))) (old-fg (car (gimp-palette-get-foreground))) (border-width (+ ib-width ob-width)) (new-width (+ old-width (* border-width 2))) (new-height (+ old-height (* border-width 2))) ) ;; Start undo, make it simple. (gimp-image-undo-group-start img) ;;Add space for the border ("canvas resize") (gimp-image-resize img new-width new-height border-width border-width) ;; Create new layer for the border (set! border-layer (car (gimp-layer-new img new-width new-height type "Photo-border" 100 NORMAL ))) ;; Clear newly created layer (gimp-edit-clear border-layer) ;; Add it to image (gimp-image-add-layer img border-layer -1) ;; Outer border fill, if it is bigger than zero (cond ((> ob-width 0) (gimp-rect-select img 0 0 new-width new-height REPLACE 0 0) (gimp-rect-select img ob-width ob-width (- new-width (* ob-width 2)) (- new-height (* ob-width 2)) SUB 0 0) (gimp-palette-set-foreground ob-colour) (gimp-edit-fill border-layer 0) )) ;; Inner border fill if width is > 0 (cond ((> ib-width 0) (gimp-rect-select img ob-width ob-width (- new-width (* ob-width 2)) (- new-height (* ob-width 2)) REPLACE 0 0) (gimp-rect-select img border-width border-width old-width old-height SUB 0 0) (gimp-palette-set-foreground ib-colour) (gimp-edit-fill border-layer 0) )) ;; add the text if the text has size ;; doing it very iteratively and unschemy (cond ((> (string-length text) 0) (let ((text-size '()) (text-width '()) (text-height '()) (written-text '()) ) (gimp-palette-set-foreground font-colour) ;; get the extent of text when written out (set! text-size (gimp-text-get-extents-fontname text font-size PIXELS font-name)) (set! text-width (car text-size)) (set! text-height (cadr text-size)) (set! written-text (gimp-text-fontname img -1 ;; new layer (- new-width text-width ob-width) ;; x-coord (- new-height text-height) ;; y-coord text -1 TRUE ;; anti-alias font-size PIXELS ;; size is in pixels font-name)) ;; if we're to blur anything, this is the time (if (= blur-text TRUE) (plug-in-gauss-rle TRUE img (car written-text) 1.5 TRUE TRUE)) ))) ;; flatten (if (= flatten-image TRUE) (gimp-image-flatten img)) ;; Finalisation (gimp-selection-none img) (gimp-palette-set-foreground old-fg) ;; End UNDO (gimp-image-undo-group-end img) ;; Display our work (if (= work-on-copy TRUE) (gimp-display-new img)) (gimp-displays-flush) )) ;; Default values are for really big pictures, scale down if you work with ;; small pictures. Unfortunately these defaults can't figure out the size ;; of your image due to limitations in gimp. (script-fu-register "script-fu-border-with-copyright" _"/Script-Fu/Decor/Double Border with Copyright..." "Add a border around an image with copyright note" "Frank Ufie (fufie@boblycat.org) [Based on photo-border by: Zigmar (antokol@isdn.net.il)]" "Fufie (was: Zigmar)" "28/10/2004" "" SF-IMAGE "Input Image" 0 SF-DRAWABLE "Input Drawable" 0 SF-ADJUSTMENT _"Inner border width" '(8 0 2000 1 10 0 1) SF-COLOR _"Inner border colour" '(255 255 255) SF-ADJUSTMENT _"Outer border width" '(50 0 2000 1 10 0 1) SF-COLOR _"Outer border colour" '(0 0 0) SF-STRING _"Text" "\302\251 f ufie, 2004" SF-FONT _"Font" "Utopia" SF-ADJUSTMENT _"Font Size (pixels)" '(40 2 1000 1 10 0 1) SF-COLOR _"Text colour" '(255 255 255) SF-TOGGLE "Blur text" TRUE SF-TOGGLE "Work on copy" FALSE SF-TOGGLE "Flatten image" TRUE )