开发者社区> 问答> 正文

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

展开
收起
爱吃鱼的程序员 2020-06-12 15:46:39 945 0
2 条回答
写回答
取消 提交回答
  • Python-Pillow升级到最新版本

    2021-02-20 15:17:56
    赞同 展开评论 打赏
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    参看:http://my.oschina.net/cppblog/blog/500308

    2020-06-12 15:46:57
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载