使用PIL在python中打开并显示.png文件 [英] Open and display .png file in python using PIL

查看:312
本文介绍了使用PIL在python中打开并显示.png文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打开一个png图像文件并显示它.我可以使用PIL打开文件

I need to open a png image file and display it. I am able to open the file using PIL

from PIL import Image
f = Image.open("file.png").show()

我收到一条错误消息:错误导致无法显示视频或图像,错误代码0x800706ba

I am getting a error message: " an error is preventing the video or image from being displayed Error code 0x800706ba

有人知道这里出了什么问题吗?

Does anyone know whats going wrong here?

推荐答案

在Windows上,PIL使用注册的任何程序打开一个临时.BMP文件.程序返回时,将删除临时文件.

On Windows, PIL uses whatever program is registered to open a temporary .BMP file. When the program returns, the temporary file is deleted.

到目前为止,最常见的问题是程序甚至在打开文件之前就发回返回代码,并且在打开文件之前先将其删除.不幸的是,Windows Vista和7中的默认查看器存在此问题. XP使用Microsoft图像和传真查看器就可以了.

By far the most common problem is that the program sends back a return code even before it even opens the file, and the file is deleted before it can be opened. Unfortunately the default viewer in Windows Vista and 7 has this problem; XP used the Microsoft Image and Fax viewer which was OK.

您可以使用文件资源管理器来更改与.BMP文件关联的程序.

You can use File Explorer to change the program associated with .BMP files.

这篇关于使用PIL在python中打开并显示.png文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆