[lug] gimp scripting questions

D. Stimits stimits at comcast.net
Mon Feb 26 20:23:22 MST 2007


I found a need to script gimp, and to use it in batch mode. Nope, ImLib 
won't do, it doesn't have all of the abilities of gimp, especially 
related to postscript (not to say imlib does not have an ability with 
postscript, I just find it to be inferior to what I can do with gimp).

So I created a python plug-in, which works great interactively. I added 
this to my ~/.gimp-2.2/plug-ins/. Then I found the following problems...

First, as a non-script-fu plugin, it can't be called from the batch mode 
directly (at least not in non-experimental versions). So a 
scheme/script-fu script can be used to call the python plug-in, via 
plug_in_script_fu_eval. Unfortunately, I don't know how to pass image 
and drawable parameters. In fact, it seems that all python-fu plugins 
require the plugin to accept the first two arguments of image and 
drawable. I am at a loss of how to use plug_in_script_fu_eval to pass 
image and drawable.

So I tried to create a variation which uses only file names, and tries 
to load this, but it fails since it needs image and drawable just to 
call the python-fu plugin. I noticed that the script-fu version is in 
the gimp-2.2/scripts/ directory, rather than gimp-2.2/plug-ins/. It 
appears though that only script-fu is recognized in this directory.

Long story short, I would like to use a python script to batch edit 
images named as files on the command line. In part I want it to be 
python because I have plans to marry this to a PostgreSQL db, which 
might be a tad difficult in script-fu.

Here's a basic attempt to use script-fu as a command via 
plug_in_script_fu_eval on the command line:
gimp --verbose --console-messages \
    --no-data --no-interface \
    --batch-interpreter "plug_in_script_fu_eval" \
    --batch \
    "(python_fu_do_my_stuff RUN-NONINTERACTIVE \"$RAW_IMAGE\" True)" \
    "(gimp-quit 0)"

The python plugin in question takes an image and the boolean is whether 
to force to grayscale. All I get is the terribly descriptive message 
(and this is with verbose flag on):
batch command: experienced an execution error.

Is it possible to create a python script that does not require drawable 
and image, i.e., not interactive?

Is it possible to create a python script that shows up in the main 
toolbox Xtns menu without loading an image (e.g., similar to 
<Toolbox>/Xtns/Python-Fu/Console)?

What is the difference between a script or plugin loaded in 
.gimp-2.2/scripts/ and .gimp-2.2/plug-ins/ (I suspect scripts is for all 
script-fu, and plug-ins for non-script-fu)?

Is it possible to use "plug_in_script_fu_eval" to call a python plug-in 
from batch mode for a plugin that requires an image and drawable?

D. Stimits, stimits AT comcast DOT net

PS: Has anyone here experimented with the 2.3.x release environment 
variable for choosing interpreter? If so, has it worked well?



More information about the LUG mailing list