0

我试过http://mail.python.org/pipermail/image-sig/2010-June/006313.html,但我仍然收到错误

dreampuf@HX:~/hub/lweibo$ python2.7 lweibo.py 
Traceback (most recent call last):
  File "lweibo.py", line 235, in <module>
    lweibo_render(107906)
  File "lweibo.py", line 228, in lweibo_render
    p = LPic(a_body, a_title, a_ukey_nickname, a_ukey_img, a_create)
  File "lweibo.py", line 114, in __init__
    a_ukey_img.save("s.png", "PNG", qualty=100)
  File "/Users/dreampuf/opt/macports/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Pillow-1.7.7-py2.7-macosx-10.7-x86_64.egg/PIL/Image.py", line 1406, in save
    self.load()
  File "/Users/dreampuf/opt/macports/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Pillow-1.7.7-py2.7-macosx-10.7-x86_64.egg/PIL/ImageFile.py", line 215, in load
    raise_ioerror(e)
  File "/Users/dreampuf/opt/macports/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Pillow-1.7.7-py2.7-macosx-10.7-x86_64.egg/PIL/ImageFile.py", line 52, in raise_ioerror
    raise IOError(message + " when reading image file")
IOError: broken data stream when reading image file

然后我尝试使用Macports安装jpeg6b,但它提醒我,jpeg6b版本太旧并重命名为jpeg

dreampuf@HX:~/lweibo$ sudo port install jpeg6b
Password:
--->  Configuring jpeg6b
Error: jpeg6b has been renamed to jpeg. Please install jpeg instead.
Error: Target org.macports.configure returned: obsolete port
Log for jpeg6b is at: /Users/dreampuf/opt/macports/var/macports/logs/_Users_dreampuf_opt_macports_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_jpeg6b/jpeg6b/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>

但是jpeg的版本是8d。

 dreampuf@HX:~/hub/lweibo$ port installed jpeg
 The following ports are currently installed:
  jpeg @8d_0 (active)

我知道这个错误的原因。但我无法在我的系统中安装 jpeg6b ,或者无法重新安装 PIL 以使用 jpeg6b

4

1 回答 1

0

我不明白您写出 PNG 的第一个示例与讨论 jpeg 问题之间的相关性。

如果您的 libjpeg 依赖于 macports,那么为什么不使用它来安装 PIL 呢?
在构建 PIL 时,您可以告诉它在哪里寻找 JPEG 库: export JPEG_ROOT=/usr/local/include

我建议删除 PIL,删除 libjpeg... 然后重新安装最新的 jpeg,然后重建 PIL。

尝试使用 pip 安装 PIL:pip install -U PIL

于 2012-04-11T03:43:18.590 回答