Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to close gimp with batch command?
#3
Then it just get an error saying "python-eval.py has crashed. The plugin python-eval.py has crashed."

This is how i invoke my script:


Quote:"C:\Program Files\GIMP 2\bin\gimp-console-2.8.exe" -idf --batch-interpreter python-fu-eval -b "import sys;sys.path=['.']+sys.path;import PDF;PDF.process('%1','%2');" -b "pdb.gimp_quit(1)"


This is my script:


Code:
import os,time,sys,glob,re
from gimpfu import *

rxcountpages = re.compile(r"/Type\s*/Page([^s]|$)", re.MULTILINE|re.DOTALL)

#Convert a single pdf file
def process(infile, outfile):
    print "Processing file %s " % infile
    
    for x in range(1,countPages(infile) + 1):
        countStr = str(x)
        pdb.file_ps_load_setargs(100, 0, 0, 0, countStr, 6, 2, 2)
        image = pdb.file_ps_load(infile,infile)
        drawable = pdb.gimp_image_get_active_layer(image)
        print "File %s loaded OK" % infile
        print outfile
        filename, file_extension = os.path.splitext(outfile)
        output = filename + "_" + countStr + ".jpg"
        print "Saving to %s" % outfile
        pdb.file_jpeg_save(image, drawable, output, output, 0.9,0,1,0,"",0,1,0,0)
        print "Saved to %s" % outfile
        pdb.gimp_image_delete(image)
        print "---------"
    
def countPages(filename):  
    data = file(filename,"rb").read()  
    return len(rxcountpages.findall(data))

#Convert all files in a directory
def run(directory):
    start=time.time()
    print "Running on directory \"%s\"" % directory
    for infile in glob.glob(os.path.join(directory, '*.pdf')):
        process(infile)
    end=time.time()
    print "Finished, total processing time: %.2f seconds" % (end-start)
if __name__ == "__main__":
    print "Running as __main__ with args: %s" % sys.argv

Please help....
Reply


Messages In This Thread
How to close gimp with batch command? - by flixe - 06-19-2017, 01:07 PM
RE: How to close gimp with batch command? - by flixe - 06-19-2017, 01:27 PM

Forum Jump: