[Tutor] cannot convert eps to png using PIL

Chris Fuller cfuller084 at thinkingplanet.net
Fri Oct 16 07:17:53 CEST 2009

It's trying to launch GhostScript, and failing.  The broken pipe is a clue 
that its trying to communicate with external software.  Most likely, you 
don't have ghostscript installed.  Google Ghostscript and you should find 
instructions for installing on windows (I'm fairly sure there is a port).  As 
for getting it to work with PIL, I'd just try getting it on your path 
(os.environ['PATH'] should work, too).  But you want to talk to the 
GhostScript folks; this isn't a Python problem, and there isn't an alternate 
solution that is more Pythonic.


On Thursday 15 October 2009 23:23, LL wrote:
> Hi.. I also asked this question on the imaging group but thought people
> here might have insights as well..
> all of the following code executes interactively except the last line.
> Converting a .jpg file to .png works fine. I'm using the PIL version for
> Python 2.6. Any suggestions will be greatly appreciated. Thanks, Lance
> ------------------------------------
> PythonWin 2.6.3 (r263:75183, Oct  5 2009, 14:41:55) [MSC v.1500 32 bit
> (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see
> 'Help/About PythonWin' for further copyright information.
> >>> import os
> >>> import zlib
> >>> import Image
> >>> os.chdir("c:\\foo")
> >>> img = Image.open("foo1.eps")
> >>> img.save("foo1.png")
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in <module>
>   File "C:\Python26\lib\site-packages\PIL\Image.py", line 1372, in save
>     self.load()
>   File "C:\Python26\lib\site-packages\PIL\EpsImagePlugin.py", line 283, in
> load self.im = Ghostscript(self.tile, self.size, self.fp)
>   File "C:\Python26\lib\site-packages\PIL\EpsImagePlugin.py", line 72, in
> Ghostscript gs.write(s)
> IOError: [Errno 32] Broken pipe

More information about the Tutor mailing list