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

Script-Fu error ... GUI shows different image selection than what script gets

This discussion is connected to the gimp-developer-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.

Roland Roberts
2002-09-05 17:48:10 UTC (over 21 years ago)

Script-Fu error ... GUI shows different image selection than what script gets

I have a script-fu set up which has the following initialization:

(script-fu-register "script-fu-astro-rescale-for-web" "/Xtns/Script-Fu/Astronomy/Scale for Web" "Rescale current image to \"standard\" sizes for web display" "Roland B. Roberts "
"Roland B. Roberts "
"4 September 2002"
""
SF-IMAGE "Image" 0
SF-VALUE "Size List" "'(1600 1280 1024 800 640 320 160)")

When the script is run by selecting it from the menu, an option list is presented which shows the current (and only, in this case) as selected. If I simply hit "Okay", I get the following error:

Script-Fu Error while executing (script-fu-astro-rescale-for-web 0 '(320)) ERROR: Procedural database executinog failed: (gimp_image_width 0)

The problem is that my image is *not* image 0. It is image 5. I realize I have 0 as a default and most of the time that will probably make sense. But why is it showing me image 5 in the option list and then not using it. If I click on the option list and "select" the only image showing, it works correctly.

Also, I tried evaluating (gimp-image-list) in the Script-Fu console and there really is only one image; i.e., I don't have any invisible ones hanging around.

roland

Simon Budig
2002-09-05 18:24:41 UTC (over 21 years ago)

Script-Fu error ... GUI shows different image selection than what script gets

Roland Roberts (roland@astrofoto.org) wrote:

I have a script-fu set up which has the following initialization:

[... The default value of SF_IMAGE gets returned even if there is just one image open ...]

The problem is that my image is *not* image 0. It is image 5. I realize I have 0 as a default and most of the time that will probably make sense. But why is it showing me image 5 in the option list and then not using it. If I click on the option list and "select" the only image showing, it works correctly.

I can reproduce this behaviour and I think it is a bug. If the user sees the entry to be correct he is likely to not click on the image-option menu. However, the GUI will happily pass the default value to the script.

To work around this: You could use an invalid image ID (for example -1) as the default value. So you can easily check if this is a real image ID or the default value. You could for example query (gimp-images-list) for the ID of the image. But I think this behaviour should be fixed.

Another suggestion: You use SF_VALUE for the size of your images. It most probably would be better to use SF-OPTION "Size List" '("1600" "1280" "1024" ...))

you then get an integer 0,1,2 indicating the selected option. This could be translated to the intended value by (nth index '(1600 1280 1024 ...)).

I will file a bugreport for the other issue.

Bye, Simon

Roland Roberts
2002-09-05 19:55:06 UTC (over 21 years ago)

Script-Fu error ... GUI shows different image selection than what script gets

"Simon" == Simon Budig writes:

Simon> I can reproduce this behaviour and I think it is a bug. [...]

Simon> To work around this: You could use an invalid image ID (for Simon> example -1) as the default value. So you can easily check Simon> if this is a real image ID or the default value. You could Simon> for example query (gimp-images-list) for the ID of the Simon> image. But I think this behaviour should be fixed.

Hmmm, but how can I tell which image is currently "active." There is gimp-image-active-drawable to find which layer is active. But if I have more than one image open (not going to happen very often in my case, but sometimes...) just looking in gimp-images-list won't help.

Simon> Another suggestion: You use SF_VALUE for the size of your Simon> images. It most probably would be better to use Simon> SF-OPTION "Size List" '("1600" "1280" "1024" ...))

Actually, in this case, I *do* want a list. I want it to produce a set of reduced images at each of the sizes listed.

[...] Simon> I will file a bugreport for the other issue.

Thanks.

roland

Simon Budig
2002-09-05 19:59:49 UTC (over 21 years ago)

Script-Fu error ... GUI shows different image selection than what script gets

Roland Roberts (roland@astrofoto.org) wrote:

"Simon" == Simon Budig writes:

Simon> I can reproduce this behaviour and I think it is a bug. [...]

Simon> To work around this: You could use an invalid image ID (for Simon> example -1) as the default value. So you can easily check Simon> if this is a real image ID or the default value. You could Simon> for example query (gimp-images-list) for the ID of the Simon> image. But I think this behaviour should be fixed.

Hmmm, but how can I tell which image is currently "active." There is gimp-image-active-drawable to find which layer is active. But if I have more than one image open (not going to happen very often in my case, but sometimes...) just looking in gimp-images-list won't help.

You cannot. There is no real concept of a "active" image. This is the primary reason, why there is no "save" entry in the toolbox menu.

If you register your script in the context menu of the image () you always get the image/drawable the user operates on as the first parameter.

Bye,
Simon

Roland Roberts
2002-09-05 20:03:42 UTC (over 21 years ago)

Script-Fu error ... GUI shows different image selection than what script gets

"Simon" == Simon Budig writes:

Simon> [...] There is no real concept of a "active" image. This is Simon> the primary reason, why there is no "save" entry in the Simon> toolbox menu.

Simon> If you register your script in the context menu of the Simon> image () you always get the image/drawable the user Simon> operates on as the first parameter.

Thanks. This makes sense and, in fact, it really makes more sense to put my script in either the image or file context menu since I want it to both rescale and save the results.

roland