Not getting any output or errors ghostscript python
No tif image is being generated anyone see the error? I am not receiving any errors. I am now seeing the message that ghosscript is running, still not getting an output tif though. from output I am now get开发者_StackOverflowting 'GPL Ghostscript 9.02 (2011-03-30)\nCopyright (C) 2010 Artifex Software, Inc. All rights reserved.\nThis software comes with NO WARRANTY: see the file PUBLIC for details.\n' getting closer
Edited made changes as suggested by comments**
from subprocess import Popen, PIPE,STDOUT
output = Popen([
r'C:\Program Files (x86)\gs\gs9.02\bin\gswin32c.exe',
'-dNOPAUSE',
'-dBATCH',
'-sDEVICE=tiffg4',
'-dDEBUG',
'-r196X204',
'-sPAPERSIZE=a4',
'-sOutputFile=%s' % (r'C:\Python25\pdfmining\page.tif'),
'%s' %(r'C:\Python25\pdfmining\nca.pdf'),
],stdout=PIPE,stderr = STDOUT).communicate()[0]
I don't see an input file for your command. Add the full path to an input file (PDF, PostScript, Encapsulated PostScript or AI) as the last argument, and your TIFFs should be generated...
Also, remove the -q
. It tells Ghostscript to remain 'quiet'.
Lastly, you could add a -dDEBUG
to your commandline. It tells Ghostscript to output lots of debugging information.
Some issues with your code:
You need to use raw strings so that the backslashes will not be treated as escape sequences.
e.g.
r'C:\Python25\pdfmining\nca.pdf'
instead of'C:\Python25\pdfmining\nca.pdf'
.The
self._
looks out of place here:'self._C:\Program Files (x86)\gs\gs9.02\bin'
It looks like you're passing the directory and executable filename as separate arguments. They should be together as the path of the executable file.
You may also want to capture the
stderr
so that you see the error messages, for example by usingstderr=STDOUT
to join stderr output with stdout.
精彩评论