GIMP Chat http://gimpchat.com/ |
|
Ways to execute a gimp python script from the command line http://gimpchat.com/viewtopic.php?f=9&t=15024 |
Page 1 of 1 |
Author: | vA+6Q-Hv[BX] [ Tue Dec 06, 2016 5:03 pm ] |
Post subject: | Ways to execute a gimp python script from the command line |
The 3 examples below are based on: http://stackoverflow.com/questions/5794 ... mmand-line I've always gone to imagemagick when doing batch, but was wondering if I could do everything with gimp. I was trying to answer the following questions: - How can you easily execute a gimp python script from the command line? - Does the script have to be registered? * Do all registered scripts appear in a gimp menu? - How do you pass in parameters? I came up with 3 ways below. Are there any other ways to execute gimp python scripts? At this time (newbie to gimp scripts and python,) I like Option 1 the best because I don't have to remember a long command or register the script in gimp. Parameters are easily passed on the command line. Option 2 doesn't register the script, but I could not figure out how to pass a single file to the script (sample.xcf). Option 3 registers the script. Parameters are passed via the parameter section of the register function. Execute 1: ./save-xcf-to-png-01.sh sample.xcf Code: Select all #!/bin/bash Execute 2: gimp -idf --batch-interpreter=python-fu-eval -b - < save-xcf-to-png-02.py Code: Select all # Note required here, see: /usr/lib/gimp/2.0/plug-ins/python-eval.py Execute 3: gimp -idf -b '(python-fu-save-xcf-files-to-png RUN-NONINTERACTIVE "sample.xcf")' -b '(gimp-quit 0)' Code: Select all from gimpfu import * |
Author: | ofnuts [ Wed Dec 07, 2016 3:05 am ] |
Post subject: | Re: Ways to execute a gimp python script from the command line |
One of my script does: Code: Select all gimp-2.6 -idf --batch-interpreter python-fu-eval -b 'import sys; sys.path=["."]+sys.path;import batch;batch.run("./images")' -b 'pdb.gimp_quit(1)' So the parameter "./images" is passed as part of the code to run... |
Author: | vA+6Q-Hv[BX] [ Wed Dec 07, 2016 8:06 pm ] |
Post subject: | Re: Ways to execute a gimp python script from the command line |
ofnuts wrote: One of my script does: Code: Select all gimp-2.6 -idf --batch-interpreter python-fu-eval -b 'import sys; sys.path=["."]+sys.path;import batch;batch.run("./images")' -b 'pdb.gimp_quit(1)' So the parameter "./images" is passed as part of the code to run... Ahhh, good one. I removed the "pdb.gimp_quit(1)" from the command line and added it to the script. Execute 4: gimp -idf --batch-interpreter=python-fu-eval -b 'import sys; sys.path=["."]+sys.path;import save2png;save2png.convert("sample.xcf")' Code: Select all #!/usr/bin/python |
Page 1 of 1 | All times are UTC - 5 hours [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |