Post Reply 

Need help with basic Python script

Jun 7, 2011, 05:08
Post: #1
Need help with basic Python script
Hi all,

I am trying to use gimp at work to view a series of images one by one while working form the command line. So far, I am just experimenting with a basic script:

#!/usr/bin/env python

from gimpfu import *

infile = "gstest.JPG"

image = pdb.gimp_file_load(infile, infile)

display = pdb.gimp_display_new(image)

I am running this form the command line with:
gimp -idf --batch-interpreter python-fu-eval -b execfile test-gimp-python.py -b pdb.gimp_quit

but it keeps giving me
GIMP-Error: Opening '/home/collin/test-gimp-python.py' failed: Unknown file type

I know that for plugins, you need a lot more stuff - registration, etc. I just wanted to be able to run gimp, show an image, maybe zoom in and out if I have to, close the image and look at the next (I'll add the loop later). These steps work from the python console activated in gimp, so I am guessing it is possible to do form the command line. I can't seem to find any simple working examples anywhere. Can someone tell me what I am missing? Do I need all the registry stuff and have to put the script in the plug-ins directory?

Thanks.

-C
Find all posts by this user
Quote this message in a reply
Jun 7, 2011, 14:11
Post: #2
RE: Need help with basic Python script
Hi -Thanks for the reply. So I modified my start command:

gimp -idf --batch-interpreter python-fu-eval -b 'import sys; sys.path=["."]+sys.path; execfile("./test-gimp-python.py")' -b 'pdb.gimp_quit(1)'

and I got a lot farther:

(gimp:13808): GLib-WARNING **: goption.c:2132: ignoring no-arg, optional-arg or filename flags (8) on option of type 0
Traceback (most recent call last):
File "/usr/lib/gimp/2.0/python/gimpfu.py", line 771, in _run
return apply(func, params[1:])
File "/usr/lib/gimp/2.0/plug-ins/python-eval.py", line 26, in code_eval
exec code in globals()
File "<string>", line 1, in <module>
File "./test-gimp-python.py", line 9, in <module>
display = pdb.gimp_display_new(image)
RuntimeError: execution error
batch command experienced an execution error

My guess is I can't do exactly what I want to from the command line because when I run the script, gimp (the pieces I am used to - all the windows etc.) is not initialized. I will admit this is my first time trying this - I haven't grasped exactly how it works, what is possible, etc. I think I like your idea better though - I could even make it so the user could create some kind of list or list structure - you could compare multiple images side by side, etc. I can think of a lot of useful little tools to create as "plug-ins". Thanks for your suggestion. I'll give it a shot. When I get it working (which may be a while - I do this in my spare time, which I have little of) I'll let you know the results. thanks again!
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Run script on action rchav 2 831 Aug 13, 2018 14:57
Last Post: rchav
  Script Fu Errors Gimp 2.10.4 lightsaber jd3481 1 534 Aug 2, 2018 05:13
Last Post: paynekj
  Script-fu script to conversion pdf to image 4ever 12 11,091 Jul 17, 2018 16:01
Last Post: paynekj
  Problems with a bat script :( ThaUnknown_ 1 514 Mar 26, 2018 21:14
Last Post: paynekj
  Script-fu ordered file list vnicent 1 330 Mar 19, 2018 17:33
Last Post: paynekj

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS