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 -b pdb.gimp_quit

but it keeps giving me
GIMP-Error: Opening '/home/collin/' 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?


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("./")' -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/", line 771, in _run
return apply(func, params[1:])
File "/usr/lib/gimp/2.0/plug-ins/", line 26, in code_eval
exec code in globals()
File "<string>", line 1, in <module>
File "./", 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
  python-fu file_dds_save wrong number of paramters ? Thial 1 105 Jan 14, 2019 09:28
Last Post: paynekj
  Run Deskew plugin from Python-Fu console ramonvaldezz 12 3,334 Nov 18, 2018 21:48
Last Post: paynekj
  Run script on action rchav 2 1,336 Aug 13, 2018 14:57
Last Post: rchav
  Script Fu Errors Gimp 2.10.4 lightsaber jd3481 1 889 Aug 2, 2018 05:13
Last Post: paynekj
  Script-fu script to conversion pdf to image 4ever 12 14,821 Jul 17, 2018 16:01
Last Post: paynekj

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS