【问题标题】:Python 2.7 PIL open the picture of JPEG format Error, Mac LionPython 2.7 PIL打开JPEG格式错误图片,Mac Lion
【发布时间】:2012-04-11 03:26:31
【问题描述】:

我曾尝试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

【问题讨论】:

    标签: python osx-lion python-imaging-library


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 我的意思是我用jpg的图片把它粘贴到png的图片中。
    • 我使用export JPEG_ROOT=/usr/local/lib(我的jpeg6b实际路径)仍然是错误。
    • 实际尝试它指向include而不是lib怎么样?
    • 因为jpeg6b安装信息是ranlib /usr/local/lib/libjpeg.a chmod 644 /usr/local/lib/libjpeg.a ---------- -------------------------------------------------- ------------------ 库已安装在:/usr/local/lib 要链接到给定目录 LIBDIR 中已安装的库,您必须使用 `-LLIBDIR'在链接期间标记。
    • 但是标题在/usr/local/include
    猜你喜欢
    • 1970-01-01
    • 2017-09-05
    • 2020-04-21
    • 2021-12-05
    • 2017-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-25
    相关资源
    最近更新 更多