码迷,mamicode.com
首页 > Windows程序 > 详细

PIL在windwos系统下Image.show无法显示图片问题的解决方法

时间:2014-10-09 15:32:24      阅读:1575      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   for   文件   

环境:1.win7 64位

   2.python 2.7.8

   3.PIL-1.1.7.win32-py2.7

在运行一下例子时候出现问题:

#-*-coding:utf-8-*-
__author__ = Hmily
import Image
im=Image.open(pil.jpg)
print im.format,im.size,im.mode
im.show()

问题:图片无法显示

bubuko.com,布布扣

解决方法:

打开PIL安装目录:C:\Python27\Lib\site-packages\PIL

找到ImageShow.py文件,打开文件修改第99行代码

if sys.platform == "win32":

    class WindowsViewer(Viewer):
        format = "BMP"
        def get_command(self, file, **options):
            return "start /wait %s && del /f %s" % (file, file)
    register(WindowsViewer)

 将代码:

return "start /wait %s && del /f %s" % (file, file)

修改为:

return "start /wait %s && PING 127.0.0.1 -n 5 > NUL && del /f %s" % (file, file)

 重新运行代码:

bubuko.com,布布扣

  参考:http://www.thecodingforums.com/threads/python-pil-and-vista-windows-7-show-not-working.707158/    8楼

 

PIL在windwos系统下Image.show无法显示图片问题的解决方法

标签:style   blog   http   color   io   os   ar   for   文件   

原文地址:http://www.cnblogs.com/tmall/p/4013115.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!