zoukankan      html  css  js  c++  java
  • PIL在windwos系统下Image.show无法显示图片问题的解决方法

    环境: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()

    问题:图片无法显示

    解决方法:

    打开PIL安装目录:C:Python27Libsite-packagesPIL

    找到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)
    

     重新运行代码:

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

  • 相关阅读:
    TCP之Nagle算法与TCP_NODELAY
    CSPS模拟 87
    CSPS模拟 86
    CSPS模拟 85
    CSPS模拟 84
    CSPS模拟 83
    CSPS模拟 82
    CSPS模拟 81
    CSPS模拟 80
    CSPS模拟 79
  • 原文地址:https://www.cnblogs.com/tmall/p/4013115.html
Copyright © 2011-2022 走看看