如何使用tkinter控制图片的大小?

How to control the size of a picture using tkinter?

我想在m_image中控制图片的大小(比如说,我想要420x380)。
我怎么做?

import tkinter as tk

m_gui = tk.Tk()
m_image = tk.PhotoImage(file = 'pic.gif')
m_canvas = tk.Canvas(m_gui)
m_canvas.create_image(0, 0, image = m_image)
m_canvas.pack()

m_gui.mainloop()

create_image func 的前两个参数如果能给个解释就更好了

谢谢

tk 是一个图形用户界面框架,而不是图像处理程序。两种解决方案:

  1. 使用外部图像处理程序创建具有所需大小的 .bmp、.gif 或(如果使用 tcl/tk 8.6).png 文件。

  2. 安装 pillow(pip install pillow 对我有用),用它来完成所需的 image manipulation, and use its ImageTk module 到 "create and modify Tkinter BitmapImage and PhotoImage objects from PIL images"。