Post Reply 

Help with calling gimp in linux

Sep 16, 2014, 18:16
Post: #1
Help with calling gimp in linux
I have made following script in Python,


[undefined=undefined]def process(infile):
print "Processing file %s " % infile

if infile.endswith('.png'):
image = pdb.file_png_load(infile,infile)
drawable = pdb.gimp_image_get_active_layer(image)
elif infile.endswith('.jpg'):
image = pdb.file_jpeg_load(infile,infile)
drawable = pdb.gimp_image_get_active_layer(image)
....


.....
outfile=os.path.join(os.path.dirname(infile),outfile)
#originalFile=os.path.join(os.path.dirname(infile),infile)
print "Saving to %s" % outfile
# 17. saves as PNG file
pdb.file_png_save(image, ee, outfile, outfile, 1,9,1,1,1,1,1)
shutil.move(infile, './images/original')
#pdb.file_png_save(image, ee, originalFile, originalFile, 1,9,1,1,1,1,1)
print "Saved to %s" % outfile
pdb.gimp_image_delete(image)[/undefined]


Now I need to call this from linux cmd on particular image, however I don't know how? Any help is appreciated.
Find all posts by this user
Quote this message in a reply
Sep 16, 2014, 22:05 (This post was last modified: Sep 16, 2014 22:27 by INV_SIG.)
Post: #2
RE: Help with calling gimp in linux
Something like

gimp-console-2.8 -b -idf --batch-interpreter python-fu-eval -b "import sys;sys.path=[\'.\']+sys.path;import myModule;myModule.process('./images/1.jpg')" -b "pdb.gimp_quit(0)"

But it throws me an error? Unable to run plug-in GIMP2.ink. Failed to execute child process. <EXEC FORMAT ERROR>


Batch command experienced execution error.
Find all posts by this user
Quote this message in a reply
Sep 17, 2014, 00:53
Post: #3
RE: Help with calling gimp in linux
OK, I have made this script to work under Windows with this approach

import glob,sys
import os
cmd0 = 'gimp-console-2.8 -b -idf --batch-interpreter python-fu-eval -b "import sys,os;sys.path=[\'.\']+sys.path;import mymodule;mymodule.doit('
cmd1 = '\'./images/1.jpg\')" '
cmd2 = '-b "pdb.gimp_quit(0)"'
cmdfinal = cmd0 + cmd1 + cmd2


However, I need abs path to be inside cmd1? So how to achieve it, I have tried with following, however without success.

import glob,sys
import os
takeitfromhere = os.path.abspath('1.jpg')
cmd0 = 'gimp-console-2.8 -b -idf --batch-interpreter python-fu-eval -b "import sys,os;sys.path=[\'.\']+sys.path;import mymodule;mymodule.doit('
cmd1 = takeitfromhere+')" '
cmd2 = '-b "pdb.gimp_quit(0)"'
cmdfinal = cmd0 + cmd1 + cmd2

os.system(cmdfinal)

Any help is appreciated.
Find all posts by this user
Quote this message in a reply
Sep 17, 2014, 03:02
Post: #4
RE: Help with calling gimp in linux
I need this for Linux if possible. Smile)
Find all posts by this user
Quote this message in a reply
Sep 17, 2014, 03:15
Post: #5
RE: Help with calling gimp in linux
import glob,sys
import os

def dome(oaap):
cmd0 = 'gimp-console-2.8 -b -idf --batch-interpreter python-fu-eval -b "import sys,os;sys.path=[\'.\']+sys.path;import toto;'
cmd1 = 'toto.doit({0!r})'.format(oaap)
cmd2 = '"-b "pdb.gimp_quit(0)"'
cmdfinal = cmd0 + cmd1 + cmd2
os.system(cmdfinal)

if __name__ == "__main__":
a = sys.argv[1]
dome(a)


I have fixed for Windows this, however can this work for Linux too?
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  embedding icm profile in a psd generated by gimp Richar_d 1 65 Oct 13, 2017 12:00
Last Post: paynekj
  Gimp GUI icons missed massimobarbieri 1 210 Aug 23, 2017 17:51
Last Post: ofnuts
  why gimp in mac has bad performance mcheung63 1 203 Aug 20, 2017 10:13
Last Post: ythgilb
  Issue viewing GIMP-modified picture JuniorPear 1 285 Jul 6, 2017 05:03
Last Post: ythgilb
  GIMP Taking Too Long to Start (Fonts) Seta 2 338 Jun 20, 2017 16:10
Last Post: Seta

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS