python3的Pillow缩小图片报错
错误信息:
Traceback (most recent call last):
File "newbing.py", line 278, in <module>
main.main(path=path,filedate=filedate,log=log,bi=bi,fileutil=fileutil,im=im,root=root,month=nowmonth)
File "newbing.py", line 228, in main
im.formatImage(filepath,root+"small/"+month+"/"+filedate +"_small"+ imgpath)
File "/root/bingimages_py3test/src/newbingimages/UserTools.py", line 111, in formatImage
smallimg=img.resize((96,54),Image.ANTIALIAS)
File "/usr/local/python3.4/lib/python3.4/site-packages/Pillow-2.9.0-py3.4-linux-x86_64.egg/PIL/Image.py", line 1557, in resize
File "/usr/local/python3.4/lib/python3.4/site-packages/Pillow-2.9.0-py3.4-linux-x86_64.egg/PIL/ImageFile.py", line 250, in load
File "/usr/local/python3.4/lib/python3.4/site-packages/Pillow-2.9.0-py3.4-linux-x86_64.egg/PIL/ImageFile.py", line 59, in raise_ioerror
OSError: broken data stream when reading image file
源码:
class ImageUtils(object):
#Downsizing parameters according to the incoming documents to carry out image processing, under test.
def formatImage(self,filepathname,newfilesavepath):
img=Image.open(filepathname)
smallimg=img.resize((96,54))
f=FileUtils()
f.mkdir(newfilesavepath)
smallimg.save(newfilesavepath,"JPEG")
版本:
系统: CentOS release 6.6 (Final) x86_64
Python: 3.4.3
Python-Pillow版本: 2.9
已经执行过yum install libtiff-devel libjpeg-devel libzip-devel freetype-devel
lcms2-devel libwebp-devel tcl-devel tk-devel 了,把要缩放的图片下载到本地也是可以打开的.在线等,谢谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
参看:http://my.oschina.net/cppblog/blog/500308