Hi, I'm new to Script-Fu (but not to GIMP) and I'm trying to customize Double Border script by Pavel Antokolsky and Frank Ufie (http://registry.gimp.org/plugin?id=4899).
The very first thing I did is replacing old calls (beginning with gimp-palette-*) to new calls (gimp-context-*) to make it work with GIMP 2.3.x. I also changed some defaults to the ones I usually use. Then I changed menu to <Image>/Filters/Decor so that the obsolete Script-Fu menu isn't created again. There are 2 issues left 1. When I try to execute the script, I see the following message: Error during execution (script-fu-border-with-copyright 1 2 1 '(255 255 255) 5 '(0 0 0) "\302\251 Alexandre Prokoudine, 2004" "Verdana Italic" 11 '(105 81 71) FALSE FALSE FALSE) ERROR: Procedural database execution failed: (gimp-edit-clear 4) 2. When I try to undo changes that the script managed to introduce before failing, GIMP freezes i.e. stops responding. I understand that using unstable version isn't a really good idea in common cases, but for me CMS is critical. Thus, any idea about what should be fixed is highly appreciated. My version of the script is attached to this letter. Thank you in advance. Best regards, Alexandre
;; ;; Freely distributed ;; ;; Version 1.0 by Pavel Antokolsky aka Zigmar ([EMAIL PROTECTED]) ;; ;; Version 1.1 Fufie ([EMAIL PROTECTED]) ;; ;; - Improved error-checking and undo works ;; - Addded support for copyright-notice ;; - Moved script to S-Fu/Decor ;; ;; Version 1.2 Fufie ([EMAIL PROTECTED]) ;; ;; - Added blur-effect on copyright-notice ;; as suggested by Eugene ;; ;; Version 1.2.1 Alexandre Prokoudine ([EMAIL PROTECTED]) ;; ;; - changed API calls to 2.3.x ones ;; - changed position of plug-in's position in menu ;; - changed default font settings (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-context-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-context-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-context-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-context-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-context-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" _"<Image>/Filters/Decor/Double Border with Copyright..." "Add a border around an image with copyright note" "Frank Ufie ([EMAIL PROTECTED]) [Based on photo-border by: Zigmar ([EMAIL PROTECTED])]" "Fufie (was: Zigmar)" "28/10/2004" "" SF-IMAGE "Input Image" 0 SF-DRAWABLE "Input Drawable" 0 SF-ADJUSTMENT _"Inner border width" '(1 0 2000 1 10 0 1) SF-COLOR _"Inner border colour" '(255 255 255) SF-ADJUSTMENT _"Outer border width" '(5 0 2000 1 10 0 1) SF-COLOR _"Outer border colour" '(0 0 0) SF-STRING _"Text" "\302\251 Alexandre Prokoudine, 2005" SF-FONT _"Font" "Verdana Italic" SF-ADJUSTMENT _"Font Size (pixels)" '(11 2 1000 1 10 0 1) SF-COLOR _"Text colour" '(255 255 255) SF-TOGGLE "Blur text" FALSE SF-TOGGLE "Work on copy" FALSE SF-TOGGLE "Flatten image" TRUE )
_______________________________________________ Gimp-user mailing list Gimp-user@lists.xcf.berkeley.edu http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user