PIL提供了
show一种尝试检测操作系统并选择适当查看器的方法。在Unix上,它尝试调用imagemagick命令
display
或
xv。在Mac上使用
openWindows,在Windows上使用其他。
如果找不到合适的查看器,
ImageShow._viewers将为空列表。
在Raspbian,你需要观众这样安装的图像
display,
xv或
fim。(请注意,在网络上进行的搜索将显示有许多可用的图像查看器。)然后,您可以通过指定
command参数告诉PIL使用它:
image.show(command='fim')
要在Tkinter中显示图像,可以使用以下方法:
from PIL import Image, ImageTk import tkinter as tkroot = tk.Tk()img = Image.open("image.gif")tkimage = ImageTk.PhotoImage(img)tk.Label(root, image=tkimage).pack()root.mainloop()


