gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 03:36:23 25 4
gpt4 key购买 nike

当我在图像查看器中打开图像时,显示的图像名称错误(与加载的图像不同)。原始图像='image.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.png new image

我做错了什么?为什么名字不一样?

最佳答案

这是因为 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

您可以尝试通过在要显示的参数中传递字符串来更改标题。

关于python - 图像查看器python 3.5中显示的图像名称错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40320817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com