ImageTk ModuleΒΆ

doc:http://pillow.readthedocs.io/en/4.1.x/reference/ImageTk.html, http://effbot.org/imagingbook/imagetk.htm

Note

All source images in this document are derived from https://www.pexels.com (CC0 License).

try:
    import tkinter  # py3
except ImportError:
    import Tkinter as tkinter  # py2

from PIL import Image, ImageTk
#
root = tkinter.Tk()
imname = "data/srcimg14.jpg"
# PIL Images
im1 = Image.open(imname).convert("1")
size = (im1.width // 4, im1.height // 4)
# adapters for tkinter
im1 = ImageTk.BitmapImage(im1.resize(size))
im2 = ImageTk.PhotoImage(Image.open(imname).resize(size))
# These can be used everywhere Tkinter expects an image object.
tkinter.Label(root, image=im1, bd=10).grid(row=0, column=0)
tkinter.Label(root, image=im2, bd=10).grid(row=0, column=1)
#
root.mainloop()
_images/ImageTk_ss01.jpg