insert image in tkinter code example

Example 1: how to add a image in tkinter

from tkinter import *
root=Tk()
img=PhotoImage(file='sunshine.jpg')
Label(root,image=img).pack()
root.mainloop()

Example 2: 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 3: image tkinter

from tkinter import *      
root = Tk()      
canvas = Canvas(root, width = 300, height = 300)      
canvas.pack()      
img = PhotoImage(file="ball.ppm")      
canvas.create_image(20,20, anchor=NW, image=img)      
mainloop()