from tkinter import * from PIL import ImageTk, Image root=Tk() image = Image.open('path_to_your_image.png') # The (450, 350) is (height, width) image = image.resize((450, 350), Image.ANTIALIAS) my_img = ImageTk.PhotoImage(image) my_img = Label(image = my_img) my_img.pack() root.mainloop()
Here is what the above code is Doing:
1. We’re creating a Tkinter window.
2. We’re opening an image using the PIL module.
3. We’re resizing the image to fit the window.
4. We’re creating a Tkinter image from the PIL image.
5. We’re creating a Tkinter label with the image.
6. We’re displaying the label.
7. We’re running the mainloop.