michael chang wrote:
perl scripts with the GIMP module can be loaded just like any
executable script; for example, if I have a script that uses GIMP
called myfile.pl and I go to that directory and call ./myfile.pl, it
will run.
Thanks for the idea. I never thought of running the script as a
stand-alone program which uses gimp as a library. This is exactly what
I am looking for. I tried it with some code from one of my working
python plugins. I removed the "register" code and inlined the relevant
gimp calls.
Here is the simple python script:
-- begin ---
#!/usr/bin/python
from gimpfu import *
width = 100
height = 100
print "before call to gimp.Image"
img = gimp.Image(width, height, RGB)
print "after call to gimp.Image"
layer = gimp.Layer(img, "layname", width, height, RGBA_IMAGE, 100,
NORMAL_MODE)
img.add_layer(layer, 0)
pdb.gimp_image_set_active_layer(img, layer)
draw = pdb.gimp_image_get_active_drawable(img)
# fill solid red
gimp.set_foreground((255,0,0))
pdb.gimp_selection_all(img)
pdb.gimp_edit_bucket_fill(draw,0,0,100,0,0,0,0)
filename="temp.tga"
pdb.file_tga_save(img,draw,filename,filename,0,0)
gimp.delete(img)
--- end ---
The first problem was that python couldn't find the gimpfu module but
once I found it and added it to the path I ran into another problem:
$ PYTHONPATH=/usr/lib/gimp/2.0/python ./simple
before call to gimp.Image
(process:11416): GLib-CRITICAL **: g_hash_table_lookup: assertion
`hash_table != NULL' failed
LibGimpBase-ERROR **: could not find handler for message: 5
aborting...
Aborted
$
Does anyone know what any of the above errors mean? It seems to fail in
the first call to gimp i.e. gimp.Image() I'm not sure why the only
gimpfu on my system (a stable gentoo box) is located in a 2.0
directory. My gimp version is 2.2.8 and my python version is 2.4.2
The package manager claims that the gimpfu file belongs to the latest
gimp package:
# locate gimpfu
/usr/lib/gimp/2.0/python/gimpfu.py
/usr/lib/gimp/2.0/python/gimpfu.pyc
/usr/lib/gimp/2.0/python/gimpfu.pyo
# equery b /usr/lib/gimp/2.0/python/gimpfu.py
[ Searching for file(s) /usr/lib/gimp/2.0/python/gimpfu.py in *... ]
media-gfx/gimp-2.2.8-r1 (/usr/lib/gimp/2.0/python/gimpfu.py)
Am I supposed to be able to call gimp from a standalone python program
like this?
Robert.
_______________________________________________
Gimp-user mailing list
[email protected]
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user