簡體   English   中英

如果是EPS格式,則Python PIL Image.save()錯誤

[英]Python PIL Image.save() error in case of EPS format

我正在嘗試將jpeg文件轉換為eps文件。 我正在使用以下代碼:

fp=open("test.jpg",'rb')
im=Image.open(fp)
outf=open('test2.eps','wb')
im.save(outf, 'EPS')

但是,我可能遇到以下錯誤:

Traceback (most recent call last):
File "im2eps2.py", line 11, in <module> im.save(outf, 'EPS')
File "C:\Python26\Lib\site-packages\PIL\Image.py", line 1465, in save
save_handler(self, fp, filename)
File "C:\Python26\Lib\site-packages\PIL\EpsImagePlugin.py", line 353, in _save
fp = io.TextIOWrapper(NoCloseStream(fp), encoding='latin-1')
File "C:\Python26\Lib\io.py", line 1429, in __init__
self._seekable = self._telling = self.buffer.seekable()
File "C:\Python26\Lib\site-packages\PIL\EpsImagePlugin.py", line 348, in __getattr__
return getattr(self.fp, name)
AttributeError: 'file' object has no attribute 'seekable'

我將感謝您的建議。 謝謝

PS:我從其主頁(即http://www.pythonware.com/products/pil/)重新安裝了PIL,並且可以正常工作:)之前,我使用了http://www.lfd.uci.edu/~提供的Windows安裝程序。 gohlke / pythonlibs 我認為問題出在我之前安裝的二進制文件上。 目前,我有1.1.7 PIL,並且工作正常。

謝謝

根據cgohlke的說法,這是Pillow中的錯誤,並已在上個月(2014年4月1日)發布的2.4.0中修復。

錯誤報告

io.TextIOWrapper需要一個具有io.IOBase接口的對象,而不是Python 2 file對象。 使用fh = io.open('test.eps', 'wb')通過了這個階段,但是io.TextIOWrapper.write()需要Unicode字符串; 該示例因TypeError: can't write str to text stream失敗TypeError: can't write str to text stream

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM