python3的Pillow缩小图片报错

发布于 2021-11-24 09:41:45 字数 1904 浏览 830 评论 1

错误信息:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

居里长安 2021-11-25 01:53:24

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文