load image python pil tkinter code example

Example 1: how to place image in tkinter

import tkinter 
from PIL import Image, ImageTk

load= Image.open("/Users/omprakash/Desktop/Gmail-new-logo.jpg")
render = ImageTk.PhotoImage(load)
img = Label(root, image=render)
img.place(x=100, y=100)

Example 2: show image in tkinter pillow

import tkinter as tk
from PIL import Image, ImageTk

root = tk.Tk()
img = Image.open("path//to//imgage.jpg")
img = img.resize((250, 250))
tkimage = ImageTk.PhotoImage(img)
tk.Label(root, image=tkimage).grid()