balibakbar
balibakbar

Reputation: 269

Open and display .png file in python using 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()

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?

Upvotes: 3

Views: 29543

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308081

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

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.

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

Upvotes: 3

Related Questions