图像查看器python 3.5中显示的图像名称错误

2024-04-25 03:33:55 发布

您现在位置:Python中文网/ 问答频道 /正文

在图像查看器中打开图像时,显示的图像名称错误(与加载的图像不同)。原始图像图片.PNG'中的名称='tmpy4uvijg0.BMP'(新名称始终更改,请参见下图)

from PIL import Image
imName='image.PNG'
try:
    with Image.open(imName) as im:
        print(imName)
        im.show()
except IOError:
    pass

image.pngnew image

我做错什么了?为什么名字不一样?你知道吗


Tags: from图像imageimport名称pilpng错误
1条回答
网友
1楼 · 发布于 2024-04-25 03:33:55

这是因为show方法将图像保存到临时文件中,如文档中所述:

Displays this image. This method is mainly intended for debugging purposes.

On Unix platforms, this method saves the image to a temporary PPM file, and calls the xv utility.

On Windows, it saves the image to a temporary BMP file, and uses the standard BMP display utility to show it (usually Paint).

:param title: Optional title to use for the image window, where possible.

:param command: command used to show the image

您可以尝试通过在参数中传递字符串来更改标题。你知道吗

相关问题 更多 >