Open and display .png file in python using PIL

后端 未结 1 1115
时光取名叫无心
时光取名叫无心 2021-01-23 03:43

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()

1条回答
  •  北荒
    北荒 (楼主)
    2021-01-23 04:14

    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.

    0 讨论(0)
提交回复
热议问题