Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script syntax for IMAGE or DRAWABLE
#2
image and drawable are variables, that, technically in script-fu, are integers with the ID(*) of the image of "drawable" (layer/mask/channel) that you are working with.  The value comes either from:
  • an argument to your script: if you register the script properly (first two arguments are usually an image and a drawable), the active image and drawable/layer is passed to the script as an argument
  • the result of some function you called: for instance gimp-layer-new-from-visible returns the ID of the created layer
Now, if you work in the console, there is no script, so you don't get these set up automatically. The image ID is displayed in the title bar so you can use that integer value directly (in Script-fu, in Python is a bit different)).

   

Not such direct way to access the layer, but you can retrieve the id of the active drawable/layer  with (gimp-image-get-active-layer image) or (gimp-image-get-active-drawable image), or use (gimp-image-get-layer-by-name image name) to retrieve it by name (with the caveat that the name may not always be what you expect)(**).


(*) it is a gimp-wide identifier, and is not for instance the position of the layer in the stack. In general you don't need to know the actual value, you just pass it around unchanged. Checking the ID is useful only when things don't happen on the right layer so you can make sure you aren't mixing up  things in the code.

(**) these calls are fine in the console, but it you write a script, using the script arguments is a much better way.
Reply


Messages In This Thread
Script syntax for IMAGE or DRAWABLE - by slaine - 04-08-2024, 12:12 PM
RE: Script syntax for IMAGE or DRAWABLE - by Ofnuts - 04-09-2024, 07:47 AM

Forum Jump: