Re: [Gimp-user] run script located in an arbitrary directory

2005-11-26 Thread Carol Spears
On Sat, Nov 26, 2005 at 11:52:09AM -0800, Robert Kleemann wrote:
> 
> (plug-in-path "/home/robert/custom-plug-ins:/usr/lib/gimp/2.0/plug-ins")
> 
> The directories will probably change when the gimp version changes but 
> since the scripts will likely have to be changed as well it's not a big 
> deal.
> 
the ability to show the new version to the old locations will still be
there though.  through the preferences the same way.  

they try to make things backwards compatible and usually the changes
needed are minor.

carol

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] run script located in an arbitrary directory

2005-11-26 Thread Robert Kleemann
Thanks Yosh for the definitive answer.  I've never looked at the gimp's 
code base so that would be a huge effort for me to fix this small problem.


I tried Carol's solution of a custom gimprc and that seems to be a good 
enough solution.  In order to get it to work I had to first load the 
standard plugins so my gimprc looked like the following:


(plug-in-path "/home/robert/custom-plug-ins:/usr/lib/gimp/2.0/plug-ins")

The directories will probably change when the gimp version changes but 
since the scripts will likely have to be changed as well it's not a big 
deal.


Thanks to everyone for their help!

Robert.

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] run script located in an arbitrary directory

2005-11-23 Thread Manish Singh
On Mon, Nov 21, 2005 at 05:33:22PM -0800, Robert Kleemann wrote:
> 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.


 
> Am I supposed to be able to call gimp from a standalone python program 
> like this?

No, this does not work. Python-Fu scripts must be invoked from within
GIMP. I wish michael chang actually would check his facts once in a
while instead of posting wrong information.

The perl bindings do the run from the command line trick by having
GIMP run a plugin that listens on a socket for commands to evaluate. The
script will proxy over commands to the server. If no GIMP is running,
the script starts one up.

You could code up similar functionality for Python-Fu. I don't know your
skill level, but it wouldn't be too hard for someone with reasonable
Python and GIMP clue, and if done right, worthy of being folded into the
distribution.

Another option is to code up a batch mode evaluator for python. Then you
could provide arbitrary code on standard input. This is less complex
to implement than the above.

You could write a simple proxy script that lives in the plugin dir that
imports your real script and runs it.

And finally, you could follow Carol's suggestion in her earlier mail,
that of defining another plug-in dir, and optionally selecting a
different config to only pull that in when you need it. This would
require no additional code at all.

-Yosh
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] run script located in an arbitrary directory

2005-11-21 Thread Robert Kleemann

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
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] run script located in an arbitrary directory

2005-11-21 Thread Carol Spears
On Mon, Nov 21, 2005 at 12:44:38PM -0800, Robert Kleemann wrote:
> Is it possible to have gimp run a script that located in an arbitrary 
> directory?  It seems that gimp wants to run scripts from 
> ~/.gimp-n.n/[plug-ins|scripts]/
> 
File-->Preferences
there is an expander twisty for folders.  from there, you can tell gimp
to use "Plug-Ins" from other directories, effectively putting that
directory into gimps path.  this works for python and perl scripts and
your compiled c plug-ins.  the "Scripts" dialog would be the way to show
it to other script-fu containing directories.

> Given this way of using gimp, it would be very handy if I could run gimp 
> in some way so that it would run a specified script that is not located 
> in one of the standard gimp directories.   
> 
my preferences solution alone will not do this.  running "gimp --gimprc
" combined with setting the preferences differently
there would do what you need, however.  i have not tried all of this
myself, it is just the approach i would take if i needed to do this.

please let us know if this works for what you are trying to do.

carol

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] run script located in an arbitrary directory

2005-11-21 Thread michael chang
On 11/21/05, Robert Kleemann <[EMAIL PROTECTED]> wrote:
> Is it possible to have gimp run a script that located in an arbitrary
> directory?  It seems that gimp wants to run scripts from
> ~/.gimp-n.n/[plug-ins|scripts]/

> 2) It only works for scripting languages where white space is not
> significant.  This means you can't use this with python-fu (my preferred
> scripting language)
>
> Am I missing something?  Is there an obvious way to do this?

While Perl-fu is not ... at it's peak at the moment, from my memory,
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.  [In fact, this is the only way I've figured out how to run
them -- I still haven't figured out how to register a Perl-Fu script
in the menus.  Heh.]  I don't know about Python, but I can imagine it
could be possible - although would you need to open the images from
Python itself to do so?

> If there is no way to do this, would it make a good feature request?

*IF* there is no way to do this, I myself don't see anything wrong
with the idea... the only thing is I don't know when/if it'd be
completed.

--
~Mike
 - Just my two cents
 - No man is an island, and no man is unable.
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user