shellcommand-line-interfacewindows-subsystem-for-linuxgimpscript-fu

Error in first argument GIMP batch threshold in WSL


I am having trouble using the GIMP batch commands in WSL.

I have a file with several .png files and I am trying to apply threshold on all of them using the gimp batch, the documentation in gimp says how to run the commands, yet I get errors when I run a script almost copied from the documentation.

Here are some attempt-error pairs

gimp -i -b '(gimp-drawable-threshold "*.png" 6 0 0.5)' -b '(gimp-quit 0)'
batch command experienced an execution error:
Error: Invalid type for argument 1 to gimp-drawable-threshold

Similar for

gimp -i -b '(gimp-threshold "*.png" 0 0.5)' -b '(gimp-quit 0)'
batch command experienced an execution error:
Error: Invalid type for argument 1 to gimp-threshold

I couldn't find in the docs how arguments are numbered for ScriptFu in GIMP, so I first assumed that the 6 from the first attempt was wrong, but testing with gimp-threshold showed that it is alright.

Having realized that the "*.png" is likely wrong, I searched around and found people writing the filename argument with escapes (\"), but that didn't work either.

Any help would be greatly appreciated!


Solution

  • I suggest you explore the Procedure Browser in GIMP (Help>>Procedure Browser)

    But to give you the quick answer, gimp-threshold takes a drawable ID as the first parameter (which is a number) not a file name.

    You would need to write a script that opens a file and then finds the ID of the layer that you want to operate on, and presumably then saves the file.