Hi,

I seek help with migrating script-fu script from Gimp 2.2 to 2.4.

A long, long time ago I wrote script-fu script to automate adding boder to my photos [1] (just simple frame and two texts at bottom of image).

After upgrade to 2.4.0-rc2 script stoped working, first I found problem with (set! variable ...) syntax, I replaced that by (define variable ...) and now I'm getting "Procedural database execution of gimp-floating-sel-anchor failed:" error without any further explanation of problem. I've no idea what get wrong there.

    (define rtText
          (car
           (gimp-text-fontname
            img -1
            0 0
            rightText
            0
            TRUE
            fontSize PIXELS
            fontName)
           )
          )
    (define rtTextWidth   (car (gimp-drawable-width  rtText) ) )
    (define rtTextHeight  (car (gimp-drawable-height rtText) ) )
    (gimp-layer-resize rtLayer rtTextWidth rtTextHeight 0 0 )
    ; it die here :((
    (gimp-floating-sel-anchor rtText)
....^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    (gimp-layer-set-offsets rtLayer
                            (- width rtTextWidth frameSize3)
                            (- height(*0.5frameSize)(*0.5rtTextHeight)))

Is there some "script-fu migration howto"? Or maybe on this list is someone so kind to check my script... it is attached to this email.

Best regards
--
-----------------------
Jan Tomasek aka Semik
http://www.tomasek.cz/


[1] http://www.tomasek.cz/foto_vylety/Beskydy2005/5den/img/20051030_9999X_small.html


; $Id: photoBorder.scm,v 1.2 2006-07-23 12:53:18 semik Exp $

(define (gen_select_rectangle border width height)
  (let* ((n_array (cons-array 10 'double)))
    (aset n_array 0 border)
    (aset n_array 1 border)

    (aset n_array 2 (- width border))
    (aset n_array 3 border)

    (aset n_array 4 (- width border))
    (aset n_array 5 (- height border))

    (aset n_array 6 border)
    (aset n_array 7 (- height border))

    (aset n_array 8 border)
    (aset n_array 9 border)
    n_array)
)

(define (script-fu-photo-border aimg adraw 
				leftText rightText textOpacity
				fontName fontSize
				frameSize1 frameSize2 frameSize3
				color1 color2
				)

  (let* ((img (car (gimp-drawable-get-image adraw)))
         (owidth (car (gimp-image-width img)))
         (oheight (car (gimp-image-height img)))
         (frameSize (+ frameSize1 frameSize2 frameSize3))
         (frameSize23 (+ frameSize2 frameSize3))
         (width (+ owidth (* 2 frameSize)))
         (height (+ oheight (* 2 frameSize)))
         (layer (car (gimp-layer-new img
                                     width height
                                     (car (gimp-drawable-type-with-alpha adraw))
                                     "Border-Layer" 100 NORMAL-MODE)))
         (rtLayer (car (gimp-layer-new img
				       width height
				       (car (gimp-drawable-type-with-alpha adraw))
				       rightText 100 NORMAL-MODE)))
         (ltLayer (car (gimp-layer-new img
				       width height
				       (car (gimp-drawable-type-with-alpha adraw))
				       leftText 100 NORMAL-MODE)))
	 )


    (gimp-context-push)
    (gimp-image-undo-group-start img)

    (gimp-image-resize img
		       width
		       height
		       frameSize
		       frameSize)

    (gimp-image-add-layer img layer 0)
    (gimp-drawable-fill layer TRANSPARENT-FILL)

    (gimp-context-set-background (adjcolour color1 0))
    (gimp-free-select img
                      10
                      (gen_select_rectangle 0 width height)
                      CHANNEL-OP-REPLACE
                      0
                      0
                      0.0)
    (gimp-free-select img
                      10
		      (gen_select_rectangle frameSize width height)
                      1 ; CHANNEL-OP-SUBTRACT
                      0
                      0
                      0.0)
    (gimp-edit-fill layer BACKGROUND-FILL)

    (gimp-context-set-background (adjcolour color2 0))
    ; Vnejsi hrana ramecku
    (gimp-free-select img
                      10
		      (gen_select_rectangle frameSize3 width height)
                      CHANNEL-OP-REPLACE
                      0
                      0
                      0.0)
    ; Vnitrni hrana ramecku
    (gimp-free-select img
                      10
		      (gen_select_rectangle frameSize23 width height)
                      1 ; CHANNEL-OP-SUBTRACT
                      0
                      0
                      0.0)

    (gimp-edit-fill layer BACKGROUND-FILL)
    (gimp-selection-none img)

    (gimp-layer-set-opacity rtLayer textOpacity)
    (gimp-image-add-layer img rtLayer 0)
    (gimp-drawable-fill rtLayer TRANSPARENT-FILL)
    (gimp-context-set-foreground color2)
    
    (define rtText
	  (car
	   (gimp-text-fontname
	    img -1
	    0 0
	    rightText
	    0
	    TRUE
	    fontSize PIXELS
	    fontName)
	   )
	  )
    (define rtTextWidth   (car (gimp-drawable-width  rtText) ) )
    (define rtTextHeight  (car (gimp-drawable-height rtText) ) )
    (gimp-layer-resize rtLayer rtTextWidth rtTextHeight 0 0 )
    ; it die here :((
    (gimp-floating-sel-anchor rtText)
    (gimp-layer-set-offsets rtLayer
			    (- width rtTextWidth frameSize3)
			    (- height (* 0.5 frameSize) (* 0.5 rtTextHeight)))

    (gimp-layer-set-opacity ltLayer textOpacity)
    (gimp-image-add-layer img ltLayer 0)
    (gimp-drawable-fill ltLayer TRANSPARENT-FILL)

    (define ltText
	  (car
	   (gimp-text-fontname
	    img ltLayer
	    0 0
	    leftText
	    0
	    TRUE
	    fontSize PIXELS
	    fontName)
	   )
	  )
    (define ltTextWidth   (car (gimp-drawable-width  ltText) ) )
    (define ltTextHeight  (car (gimp-drawable-height ltText) ) )
    (gimp-layer-resize ltLayer ltTextWidth ltTextHeight 0 0 )
    ; it die here :((
;    (gimp-floating-sel-anchor ltText)
    (gimp-layer-set-offsets ltLayer
			    frameSize3
			    (- height (* 0.5 frameSize) (* 0.5 ltTextHeight)))
    
    (gimp-image-undo-group-end img)
    (gimp-displays-flush)

    (gimp-context-pop)

    )
  )



(script-fu-register
 "script-fu-photo-border"                            ;func name
 "Photo Border ..."                                  ;menu label
 "Creates two color photo border around       \ 
  photo. Allows author to put in name of      \
  photo and of autohor itself. Don't leave    \
  fields empty! Code is based on various      \
  lisp pieces I found in my gimp distribution."      ;description
 "Jan Tomasek <[EMAIL PROTECTED]>"                      ;author
 "author is Jan Tomasek <[EMAIL PROTECTED]> I put my code in public domain" ;copyright notice
 "23.7.2006"                                         ;date last modified
 ""                                                  ;image type that the script works on
 SF-IMAGE       "Input image"          0
 SF-DRAWABLE    "Input drawable"       0
 SF-STRING     _"Left text"            "Photo name"
 SF-STRING     _"Right text"           "Jan Tomášek 2005"
 SF-ADJUSTMENT _"Text opacity"         '(70 1  100 1 10 0 1)
 SF-FONT       _"Font"                 "Sans Italic"
 SF-ADJUSTMENT _"Font size"            '(13 1 1000 1 10 0 1)
 SF-ADJUSTMENT _"Size of frame no.1."  '( 1 1  250 1 10 0 1)
 SF-ADJUSTMENT _"Size of frame no.2."  '( 1 1  250 1 10 0 1)
 SF-ADJUSTMENT _"Size of frame no.3."  '(23 1  250 1 10 0 1)
 SF-COLOR      _"Border color"         '(0 0 0)
 SF-COLOR      _"Line color"           '(255 255 255)
 )
(script-fu-menu-register "script-fu-photo-border" "<Image>/Script-Fu/Decor")
_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply via email to