RSS/Atom feed Twitter
Site is read-only, email is disabled

Gimp-Python with no ui? (external script)

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

13 of 13 messages available
Toggle history

Please log in to manage your subscriptions.

Gimp-Python with no ui? (external script) Ministeyr 30 Mar 15:31
  Gimp-Python with no ui? (external script) Carol Spears 30 Mar 17:10
   Gimp-Python with no ui? (external script) Ministeyr 30 Mar 20:02
    Gimp-Python with no ui? (external script) Carol Spears 30 Mar 20:09
     Gimp-Python with no ui? (external script) Ministeyr 01 Apr 15:01
      Gimp-Python with no ui? (external script) Carol Spears 01 Apr 16:49
  Gimp-Python with no ui? (external script) Manish Singh 30 Mar 19:36
   Gimp-Python with no ui? (external script) Ministeyr 30 Mar 19:59
    Gimp-Python with no ui? (external script) Manish Singh 30 Mar 20:00
     Gimp-Python with no ui? (external script) Ministeyr 01 Apr 14:58
      Gimp-Python with no ui? (external script) Manish Singh 02 Apr 01:00
Gimp-Python with no ui? (external script) Alex Borghgraef 05 Apr 13:30
Gimp-Python with no ui? (external script) Alex Borghgraef 12 Apr 16:33
Ministeyr
2006-03-30 15:31:12 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

Hello,
I need to make an external Python administration script, wich occasionnally uses gimp functionnality (especially to convert to/from xcf files). Is there a way to use this functionnality without starting the ui?
I need something like that:

import gimp_noui as gimp gimp.startgimp() #start the gimp in background process pdb.file_load(whatever...)
#do something here...
pdb.file_save(whatever...)
gimp.stopgimp()
Thanks.

Carol Spears
2006-03-30 17:10:48 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

On Thu, Mar 30, 2006 at 03:31:12PM +0200, Ministeyr wrote:

I need to make an external Python administration script, wich occasionnally uses gimp functionnality (especially to convert to/from xcf files). Is there a way to use this functionnality without starting the ui?
I need something like that:

import gimp_noui as gimp gimp.startgimp() #start the gimp in background process pdb.file_load(whatever...)
#do something here...
pdb.file_save(whatever...)
gimp.stopgimp()
Thanks.

what os will you be using this on?

carol

Manish Singh
2006-03-30 19:36:17 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

On Thu, Mar 30, 2006 at 03:31:12PM +0200, Ministeyr wrote:

Hello,
I need to make an external Python administration script, wich occasionnally uses gimp functionnality (especially to convert to/from xcf files). Is there a way to use this functionnality without starting the ui?
I need something like that:

import gimp_noui as gimp gimp.startgimp() #start the gimp in background process pdb.file_load(whatever...)
#do something here...
pdb.file_save(whatever...)
gimp.stopgimp()

Just write a pygimp script normally, and call it via gimp's batch mode.

-Yosh

Ministeyr
2006-03-30 19:59:08 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

Just write a pygimp script normally, and call it via gimp's batch mode.

-Yosh

I would prefer another solution, since I have some processing to do in the external script and possibly a bunch of data to transfer back and forth, so it would make the script quite complex to have to use the batch interpreter.
By the way, I thought the batch mode only understood scheme, so it would make the whole thing even more complicated. I hope there is a simpler solution possible.

Ministeyr

Manish Singh
2006-03-30 20:00:50 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

On Thu, Mar 30, 2006 at 07:59:08PM +0200, Ministeyr wrote:

Just write a pygimp script normally, and call it via gimp's batch mode.

-Yosh

I would prefer another solution, since I have some processing to do in the external script and possibly a bunch of data to transfer back and forth, so it would make the script quite complex to have to use the batch interpreter.

Why would it?

By the way, I thought the batch mode only understood scheme, so it would make the whole thing even more complicated.

One line of scheme to call your python script won't increase the complexity appreciably.

I hope there is a simpler solution possible.

Well, it's kind of hacky yes, but it's not *complex*.

If you want something better, why don't you contribute it?

-Yosh

Ministeyr
2006-03-30 20:02:51 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

what os will you be using this on?

carol

I'm developping it for and under a Debian-testing system (on amd k7), and plan to use it possibly also on an Ubuntu Linux. I won't need windows support.

Ministeyr

Carol Spears
2006-03-30 20:09:08 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

On Thu, Mar 30, 2006 at 08:02:51PM +0200, Ministeyr wrote:

what os will you be using this on?

carol

I'm developping it for and under a Debian-testing system (on amd k7), and plan to use it possibly also on an Ubuntu Linux. I won't need windows support.

i asked because i put instructions of how to do this online.

i have a crontab that runs gimp.

that being said, it has been running for so long now, i have no idea what sort of mess it is making, but it was all so easy that it was a pleasure to put the instructions online.

carol

Ministeyr
2006-04-01 14:58:12 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

Manish Singh wrote:

>> By the way, I thought the batch mode only understood scheme, so it would make the whole thing even more complicated. >
> One line of scheme to call your python script won't increase the > complexity appreciably.

The problem is that if i have huge lists and complex python objects in my external scripts, and i want to access them in the gimp's python-fu script, i have to pass them through scheme, and thus it means converting back and forth.
I will try to adapt with pickle if it works.

> If you want something better, why don't you contribute it?

I would make a mess, since i'm not really a good programmer (plus i don't know anything about gimp's internal structure or python's...).

Ministeyr

Ministeyr
2006-04-01 15:01:31 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

Carol Spears wrote:

i asked because i put instructions of how to do this online.

i have a crontab that runs gimp.

that being said, it has been running for so long now, i have no idea what sort of mess it is making, but it was all so easy that it was a pleasure to put the instructions online.

Well, i don't know if that is exactly what i meant, but i would still be grateful if you could give me the url to that document. Thanks.

Ministeyr

Carol Spears
2006-04-01 16:49:59 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

On Sat, Apr 01, 2006 at 03:01:31PM +0200, Ministeyr wrote:

Carol Spears wrote:

i asked because i put instructions of how to do this online.

i have a crontab that runs gimp.

that being said, it has been running for so long now, i have no idea what sort of mess it is making, but it was all so easy that it was a pleasure to put the instructions online.

Well, i don't know if that is exactly what i meant, but i would still be grateful if you could give me the url to that document. Thanks.

http://carol.gimp.org/gimp/scripting/routines.html#shell

carol

Manish Singh
2006-04-02 01:00:07 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

On Sat, Apr 01, 2006 at 02:58:12PM +0200, Ministeyr wrote:

Manish Singh wrote:

By the way, I thought the batch mode only understood scheme, so it

would make the whole thing even more complicated.

One line of scheme to call your python script won't increase the complexity appreciably.

The problem is that if i have huge lists and complex python objects in my external scripts, and i want to access them in the gimp's python-fu script, i have to pass them through scheme, and thus it means converting back and forth.
I will try to adapt with pickle if it works.

You could serialize them to a temporary file, or choose from a number of IPC methods python ships with. No need to pass stuff like that over the command line.

How were you planning on doing it via your original though of having having a "gimp_noui" anyway? The issues are more or less the same.
-Yosh

Alex Borghgraef
2006-04-05 13:30:50 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

Carol Spears gimp.org> writes:

http://carol.gimp.org/gimp/scripting/routines.html#shell

Does that work with gimp 2.2? I'm also trying to get a pygimp script to run in batch mode, but it doesn't work. I tried running your python_fu_batch_resize example (adapting directories of course) but it didn't work. So I wrote a simple test script and I tried running that. This is the code:

#!/usr/bin/python

from gimpfu import *

def test(): width = 530
height= 56
bg_colour = (255, 255, 255)
# Create new image
img = pdb.gimp_image_new(width, height, RGB)
# Create and fill background layer bg_layer = pdb.gimp_layer_new(img, width, height, RGBA_IMAGE, "Background", 100, NORMAL_MODE)
pdb.gimp_context_set_background(bg_colour) pdb.gimp_drawable_fill(bg_layer,BACKGROUND_FILL) pdb.gimp_image_add_layer(img,bg_layer,0) pdb.gimp_display_new(img)

register("Test",
"", "", "", "", "",
"/Xtns/Python-Fu/Test",
"RGB*, GRAY*",
[],
[],
test
)

main()

I called gimp like this
gimp-2.2 -i -b '(Test RUN-NONINTERACTIVE)' -b '(gimp-quit 0)'

And I got these messages:
No batch interpreter specified, using the default 'plug_in_script_fu_eval'. batch command: experienced an execution error. batch command: experienced an execution error.

The script works normally when called from within gimp, so I don't really see why it should fail, unless gimp doesn't process python in batch mode. What am I doing wrong here?

--
Alex

Alex Borghgraef
2006-04-12 16:33:22 UTC (about 18 years ago)

Gimp-Python with no ui? (external script)

Alex Borghgraef gmail.com> writes:

Ok, I found the problem: the plugin is registered under the name "Test", which works under gimp, but not in batch mode, which requires "python-fu-Test". Weird thing is that even if I keep "Test" as name in the register call, a call in batch mode to "python-fu-Test" will work.

-- Alex