python3的Pillow缩小图片报错?报错-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

python3的Pillow缩小图片报错?报错

爱吃鱼的程序员 2020-06-12 15:46:39 30

错误信息:

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 <br>     lcms2-devel libwebp-devel tcl-devel tk-devel 了,把要缩放的图片下载到本地也是可以打开的.在线等,谢谢。

BI Linux Python
分享到
取消 提交回答
全部回答(1)
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程