gpt4 book ai didi

python - StringIO 无法识别图像文件错误

转载 作者:行者123 更新时间:2023-11-28 16:31:50 34 4
gpt4 key购买 nike

我正在使用以下代码在线检索图像:

import Image
import urllib2
import cStringIO

url = 'http://storage.googleapis.com/bloomsky-img/k65x5Kvpyc3W08jBqJ1kqZqnnZapoQ==.jpg'
img = urllib2.urlopen(url).read()
# error occurred when executing the line below
im = Image.open(cStringIO.StringIO(img))
im.verify()
# must reload the image after verify method !!
im = Image.open(cStringIO.StringIO(img))
im.save('name', 'JPEG')

运行时,它会给我 image not valid and error code is cannot identify image file <StringIO.StringIO instance at 0x7f6825b12e18>错误。但相同的代码在我的 Mac 上运行完美。只有当我将代码部署到 Ubuntu 服务器时,我才遇到这样的问题。我检查了文档,我想我正在使用 StringIO以正确的方式。有人可以帮忙吗?非常感谢。

最佳答案

我刚刚使用 pip install Pillow 在几乎全新的 Ubuntu 14.04 上安装了 Pillow。安装成功。但是,请查看安装摘要:

    --------------------------------------------------------------------
PIL SETUP SUMMARY
--------------------------------------------------------------------
version Pillow 2.8.2
platform linux2 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2]
--------------------------------------------------------------------
*** TKINTER support not available
(Tcl/Tk 8.6 libraries needed)
*** JPEG support not available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
*** FREETYPE2 support not available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
To check the build, run the selftest.py script.
changing mode of build/scripts-2.7/pilconvert.py from 644 to 755
changing mode of build/scripts-2.7/pildriver.py from 644 to 755
changing mode of build/scripts-2.7/pilfile.py from 644 to 755
changing mode of build/scripts-2.7/pilprint.py from 644 to 755
changing mode of build/scripts-2.7/pilfont.py from 644 to 755
changing mode of [...]
Successfully installed Pillow-2.8.2

看到那边的*** JPEG 支持不可用了吗?我认为这是关键...

关于python - StringIO 无法识别图像文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31126493/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com