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楼

  • 相关阅读:
    react 滑动删除组件
    004-Java进制转换
    003-JavaString数据类型
    002-Java数据类型
    001-Java命名规范
    【leetcode】804
    【MySQL】基本语句
    【python】
    hiveSql常见错误记录
    【数据库】-基本特性
  • 原文地址:https://www.cnblogs.com/tmall/p/4013115.html
Copyright © 2011-2022 走看看