RSS/Atom feed Twitter
Site is read-only, email is disabled

Error while executing script (Script Stop Working in Windows 2.6.3)

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

5 of 6 messages available
Toggle history

Please log in to manage your subscriptions.

Error while executing script (Script Stop Working in Windows 2.6.3) D.Jones (aka) Capnhud 13 Dec 09:37
  Error while executing script (Script Stop Working in Windows 2.6.3) Kevin Cozens 13 Dec 19:58
   Error while executing script (Script Stop Working in Windows 2.6.3) saulgoode@flashingtwelve.brickfilms.com 14 Dec 16:15
    Error while executing script (Script Stop Working in Windows 2.6.3) saulgoode@flashingtwelve.brickfilms.com 14 Dec 16:22
mailman.1.1229198403.18033.... 07 Oct 20:19
  Error while executing script (Script Stop Working in Windows 2.6.3) D.Jones (aka) Capnhud 14 Dec 11:25
D.Jones (aka) Capnhud
2008-12-13 09:37:20 UTC (about 16 years ago)

Error while executing script (Script Stop Working in Windows 2.6.3)

I had been using a script that worked fine in gimp 2.4, but when I tried to recently use this script in Windows 2.6.3 I got the following error:

http://my.opera.com/capnhud/albums/showpic.dml?album=309313&picture=8928433

The script that I was using is this:

; Script to create a gradient from an image of a gradient ; Rob Antonishen

(define (script-fu-gradient-from-image img inLayer inSegments inSmooth inName) (let*
(
(img (car (gimp-image-duplicate img))) ;create a duplicate (width (car (gimp-image-width img))) (height (car (gimp-image-height img))) (segments (truncate inSegments))
(colors (+ segments (if (= inSmooth TRUE) 1 0))) (theGradient "")
(counter 0)
)

; it begins here
(gimp-image-undo-group-start img)

;flatten inage and get drawable (layer) (set! inLayer (car (gimp-image-merge-visible-layers img 1)))
; blur then resize to number of colors by 1 (gimp-image-scale img colors 1)

;create new gradient
(set! theGradient (car (gimp-gradient-new inName))) (gimp-context-set-gradient theGradient)
;subdivide
(gimp-gradient-segment-range-split-uniform theGradient 0 0 segments)

(while (< counter segments) (gimp-gradient-segment-set-left-color theGradient counter (car (gimp-image-pick-color img inLayer counter 0 FALSE FALSE 0)) 100) (gimp-gradient-segment-set-right-color theGradient counter (car (gimp-image-pick-color img inLayer (+ counter (if (= inSmooth TRUE) 1 0)) 0 FALSE FALSE 0)) 100) (set! counter (+ counter 1))
)

;done
(gimp-image-undo-group-end img)
(gimp-image-delete img)
)
)

(script-fu-register "script-fu-gradient-from-image" "/Colors/Gradient from Image..." "Dreate a gradient from an image of a gradient." "Rob Antonishen" "Rob Antonishen" "2008"
""
SF-IMAGE "image" 0 SF-DRAWABLE "drawable" 0 SF-ADJUSTMENT "Segments in the gradient" (list 25 2 1024 1 10 0 SF-SLIDER) SF-TOGGLE "Smooth Gradient" TRUE SF-STRING "Gradient Name" "Gradient From Image"

what is the correct type for argument 3?

Kevin Cozens
2008-12-13 19:58:16 UTC (about 16 years ago)

Error while executing script (Script Stop Working in Windows 2.6.3)

D.Jones (aka) Capnhud wrote:

(colors (+ segments (if (= inSmooth TRUE) 1 0)))

[snip]

(while (< counter segments)
(gimp-gradient-segment-set-left-color theGradient counter (car (gimp-image-pick-color img inLayer counter 0 FALSE FALSE 0)) 100) (gimp-gradient-segment-set-right-color theGradient counter (car (gimp-image-pick-color img inLayer (+ counter (if (= inSmooth TRUE) 1 0)) 0 FALSE FALSE 0)) 100) (set! counter (+ counter 1))
)

[snip]

what is the correct type for argument 3?

The procedure database indicates that a FLOAT (ie. a numerical value) is expected for argument 3 of gimp-image-pick-color. Your problem is due to invalid use of the "=" operator in the two if statements shown above.

Your code has "(if (= inSmooth TRUE) 1 0)" where in Smooth is a boolean value provided by the SF-TOGGLE. The "=" operator is for use when comparing numbers, not booleans. Since inSmooth is a boolean, change your if statement to read (if inSmooth 1 0)

D.Jones (aka) Capnhud
2008-12-14 11:25:16 UTC (about 16 years ago)

Error while executing script (Script Stop Working in Windows 2.6.3)

Message: 6
Date: Sat, 13 Dec 2008 13:58:16 -0500 From: Kevin Cozens
Subject: Re: [Gimp-user] Error while executing script (Script Stop
Working in Windows 2.6.3)
To: gimp-user
Message-ID:
Content-Type: text/plain; charset=us-ascii; format=flowed

D.Jones (aka) Capnhud wrote:

(colors (+ segments (if (= inSmooth TRUE) 1 0)))

[snip]

(while (< counter segments)
(gimp-gradient-segment-set-left-color theGradient

counter (car (gimp-image-pick-color img inLayer counter 0 FALSE FALSE 0)) 100)

(gimp-gradient-segment-set-right-color

theGradient counter (car (gimp-image-pick-color img inLayer (+ counter (if (= inSmooth TRUE) 1 0)) 0 FALSE FALSE 0)) 100)

(set! counter (+ counter 1))
)

[snip]

what is the correct type for argument 3?

The procedure database indicates that a FLOAT (ie. a numerical value) is
expected for argument 3 of gimp-image-pick-color. Your problem is due to
invalid use of the "=" operator in the two if statements shown above.

Your code has "(if (= inSmooth TRUE) 1 0)" where in Smooth is a boolean value
provided by the SF-TOGGLE. The "=" operator is for use when comparing numbers,
not booleans. Since inSmooth is a boolean, change your if statement to read
(if inSmooth 1 0)

saulgoode@flashingtwelve.brickfilms.com
2008-12-14 16:15:44 UTC (about 16 years ago)

Error while executing script (Script Stop Working in Windows 2.6.3)

Quoting Kevin Cozens :

Your code has "(if (= inSmooth TRUE) 1 0)" where in Smooth is a boolean value provided by the SF-TOGGLE. The "=" operator is for use when comparing numbers,
not booleans. Since inSmooth is a boolean, change your if statement to read (if inSmooth 1 0)

I am using version 2.6.4 on Linux and my experience is that the original script functions just fine for both TRUE and FALSE values of 'inSmooth'; however, if I modify the script per your instructions then the smoothing occurs even for FALSE values of inSmooth. This is as I would expect because SF-TOGGLEs are marshalled as integer constants in the PDB interface, not booleans (correct me if I am mistaken).

I would ask Capnhud to verify whether the modified script produces the correct result after removing the '=' comparison (not just that no errors are generated). This can be done by running the script on an image consisting of only two colors, setting the number of segments to "2", and disabling smoothing. The resulting gradient should be a hard-edged transition between the two colors (as shown in this image: http://www.flashingtwelve.brickfilms.com/Temp/anomaly.png ).

When used, SF-TOGGLEs are invariably initialized to the integer constants TRUE and FALSE in existing scripts. If there has been a change whereby SF-TOGGLE are now booleans then this would seem very problematic.

saulgoode@flashingtwelve.brickfilms.com
2008-12-14 16:22:22 UTC (about 16 years ago)

Error while executing script (Script Stop Working in Windows 2.6.3)

Quoting saulgoode@flashingtwelve.brickfilms.com: This is as I

would expect because SF-TOGGLEs are marshalled as integer constants in the PDB interface, not booleans (correct me if I am mistaken).

In the above, "constants" should be corrected to "variables".