รูปภาพเป็นวัตถุที่มีประโยชน์มากในทุกแอปพลิเคชัน เราสามารถประมวลผลรูปภาพในแอปพลิเคชัน Tkinter โดยใช้แพ็คเกจ Pillow หรือ PIL ใน Python มีฟังก์ชันในตัวหลายอย่าง เช่น การโหลดรูปภาพ การแตกรูปภาพ การกำหนดค่าแผงรูปภาพ เป็นต้น
ตัวอย่าง
ในตัวอย่างนี้ เราจะเพิ่มโดยขอให้ผู้ใช้เลือกรูปภาพจากกล่องโต้ตอบ จากนั้นแสดงโดยใช้วิดเจ็ตป้ายกำกับ
#Import the Tkinter library
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
from PIL import Image, ImageTk
#Create an instance of Tkinter frame
win= Tk()
#Define the geometry
win.geometry("750x350")
win.title("Image Gallery")
def select_file():
path= filedialog.askopenfilename(title="Select an Image", filetype=(('image files','*.jpg'),('all files','*.*')))
img= Image.open(path)
img=ImageTk.PhotoImage(img)
label= Label(win, image= img)
label.image= img
label.pack()
#Create a label and a Button to Open the dialog
Label(win, text="Click the Button below to select an Image", font=('Caveat 15 bold')).pack(pady=20)
button= ttk.Button(win, text="Select to Open", command= select_file)
button.pack(ipadx=5, pady=15)
win.mainloop() ผลลัพธ์
การเรียกใช้โค้ดด้านบนจะแสดงหน้าต่างที่มีปุ่มสำหรับเลือกไฟล์รูปภาพจากไดเร็กทอรีและแสดงรูปภาพบนหน้าต่าง

ตอนนี้ เลือกรูปภาพใดก็ได้จากไดเร็กทอรีในเครื่องและแสดงผลบนหน้าจอ
