Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
migrating 2.8 bash scripts to gimp 3
#1
Hello,
new to this forum I hope someone here could help me a little bit.

As I upgraded from debian 12 to debian 13, gimp was upgraded to version 3.
I have a set of short scripts that allowed me to invoke gimp (at least until version 2.8) from a linux bash console. Now they fail, so I have to adapt them to recent changes.

The one question I still stumble on is the ability to set a drawable in my image. The former syntax does not work anymore :

Code:
(drawable (car(gimp-image-get-active-drawable image)))

so that I can't do anything on a specific layer e.g. desaturate :

Code:
(gimp-drawable-desaturate drawable 0)
How can I instruct gimp that, let's say, the drawable is layer [0] ?

Thanks in advance,
Vince.
Reply
#2
(03-09-2026, 11:53 AM)vince Wrote: Hello,
new to this forum I hope someone here could help me a little bit.

As I upgraded from debian 12 to debian 13, gimp was upgraded to version 3.
I have a set of short scripts that allowed me to invoke gimp (at least until version 2.8) from a linux bash console. Now they fail, so I have to adapt them to recent changes.

The one question I still stumble on is the ability to set a drawable in my image. The former syntax does not work anymore :

Code:
(drawable (car(gimp-image-get-active-drawable image)))

so that I can't do anything on a specific layer e.g. desaturate :

Code:
(gimp-drawable-desaturate drawable 0)
How can I instruct gimp that, let's say, the drawable is layer [0] ?

Thanks in advance,
Vince.

In this case you need gimp-image-get-selected-drawables which returns a list of the selected drawables.

Use "Help/Procedure Browser" to search for key words in the functions that you need to updated.

Also looking at the built-in scripts may help you.
Reply
#3
(03-09-2026, 04:33 PM)programmer_ceds Wrote: In this case you need gimp-image-get-selected-drawables which returns a list of the selected drawables.

Use "Help/Procedure Browser" to search for key words in the functions that you need to updated.

Also looking at the built-in scripts may help you.

Thank you for your help,

yes, I've struggled with this solution, but it seems there's something I don't do the right way to handle the array of drawables.
This works:
Code:
gimp -i --quit --batch-interpreter=plug-in-script-fu-eval -b \
"(\
    let*(\
        (image (car (file-png-load 1 \"input.png\")))\
    )\
    (gimp-file-save 1 image \"output.png\")\
)"
but this:
Code:
gimp -i --quit --batch-interpreter=plug-in-script-fu-eval -b \
"(\
    let*(\
        (image (car (file-png-load 1 \"input.png\")))\
        (drawable (vector-ref (gimp-image-get-selected-drawables image) 0))\
    )\
    (gimp-file-save 1 image \"output.png\")\
)"

throws me the following error:

Code:
Error: vector-ref: argument 1 must be: vector


I'm sorry in advance for my poor knowledge of this Scheme syntax...
Reply
#4
looking at GIMP's inbuilt scripts it could possibly be 


Code:
(drawable (vector-ref (car (gimp-image-get-selected-drawables image)) 0))
Reply
#5
100% not script-fu fan but I have come across that vector error before so trying this in a Mint 22.3 / Gimp 3.0.8 (from PPA).
Works but throws up warnings.

Quote:rich@rich-3:~$ gimp -i --quit --batch-interpreter=plug-in-script-fu-eval -b \
"(\
let*(\
(image (car (file-png-load 1 \"input.png\")))\
(drawable (vector(gimp-image-get-selected-drawables image) 0))\
)\
(gimp-file-save 1 image \"output.png\")\
)"

(script-fu:3401): scriptfu-WARNING **: 18:40:58.393: Calling Plug-In PDB procedures with arguments as an ordered list is deprecated.
Please use named arguments: (file-png-load #:run-mode 1 #:file input.png)

(script-fu:3401): scriptfu-WARNING **: 18:40:58.476: Missing arg type: GimpExportOptions
batch command executed successfully
INFO: a stray image seems to have been left around by a plug-in: "[output] (exported)"rich@rich-3:~$

Just a remark, but an option for Gimp 3 is the batcher plugin https://kamilburda.github.io/batcher/ It is remarkably flexible for processing files and images with layers.
Reply
#6
(03-09-2026, 06:50 PM)rich2005 Wrote:
Code:
rich@rich-3:~$ gimp -i --quit --batch-interpreter=plug-in-script-fu-eval -b \
"(\
   let*(\
       (image (car (file-png-load 1 \"input.png\")))\
       (drawable (vector(gimp-image-get-selected-drawables image) 0))\
   )\
   (gimp-file-save 1 image \"output.png\")\
)"

(03-09-2026, 06:37 PM)MrsP-from-C Wrote:
Code:
(drawable (vector-ref (car (gimp-image-get-selected-drawables image)) 0))


Thank you for these solutions! both suggestions succeed.

Perhaps did I miss it, is there an official documentation for the Scheme syntax? or should we just rely on a bunch of examples?

Happy to have landed on gimp-forum, thanks again.
V.

(03-09-2026, 08:25 PM)vince Wrote: Thank you for these solutions! both suggestions succeed.
but then...
Code:
gimp -i --quit --batch-interpreter=plug-in-script-fu-eval -b \
"(\
    let*(\
        (image (car (file-png-load 1 \"input.png\")))\
        (my-drawable (vector(gimp-image-get-selected-drawables image) 0))\
    )\
    (gimp-drawable-desaturate my-drawable 0)\
    (file-png-export 1 image \"output.png\")\
)"
gimp still complains, and once again I can't figure out what is going wrong. The error is:
Code:
Error: in script, expected type: numeric for argument 1 to gimp-drawable-desaturate

Does this mean that gimp-drawable-desaturate expects a number (sort of index of drawables) instead of my declared my-drawable layer?
I'm puzzled.
Reply
#7
Sorry for the previous message, I got lost. Here is a working solution (that from MrsP-from-C):


Code:
gimp -i --quit --batch-interpreter=plug-in-script-fu-eval -b \
"(\
    let*(\
        (image (car (file-png-load 1 \"input.png\")))\
        (my-drawable (vector-ref (car (gimp-image-get-selected-drawables image)) 0))\
    )\
    (gimp-drawable-desaturate my-drawable 0 )\
    (file-png-export 1 image \"output.png\")\
)"

Now, I notice the good old plug-in-colortoalpha is absent from the procedure browser. Sad
Reply
#8
As you asked for official documentation .... 
Some is here: https://developer.gimp.org/resource/script-fu/

Maybe Mark Sweeney's site might help you:
https://script-fu.github.io/funky/

Most helpful is just to look at the scripts that ship with GIMP.
Reply
#9
(03-10-2026, 06:50 AM)MrsP-from-C Wrote: As you asked for official documentation .... 
Some is here: https://developer.gimp.org/resource/script-fu/

Maybe Mark Sweeney's site might help you:
https://script-fu.github.io/funky/

Most helpful is just to look at the scripts that ship with GIMP.

Nice, the road is actually long and steep!

Do you have any suggestion about the missing plug-in-colortoalpha?
I can't find where I read it was now a GEGL filter. Is there a simple way to run such command in a "one-liner" script?

V.
Reply
#10
Looks like it's a GEGL Operation now:
https://gegl.org/operations/gegl-color-to-alpha.html

No idea how to handle those in script-fu.
But you'll find examples for similar procedures in clothify.scm, if you search for gegl:
Reply


Forum Jump: