How to Resize Image with tkinter
If You Want To resize image you Must be used Python PIL or PILLOW Library.
Full Meaning of PIL is Python Image Library. PILLOW Library has Basic Imaging Functionality.
- If You Want To Resize Image You Can Use PIL Library.
- If You Want To Rotate Image You Can Use PIL Library.
- If You Want To Transform Image You Can Use PIL Library.
It Supports All of Image Such as “jpeg”, “png”, “bmp”, “gif”, “ppm”, “tiff”.
Python Pillow package can be used for creating thumbnails, converting from one format to another and print images, etc.
Note : You Must Be Use Image Ration Like as 500x375, 250x188.
Example 01:
from tkinter import *
from PIL import ImageTk, Image
from PIL import ImageTk, Image
my_window = Tk()
my_window.title("How To Resize Image")
my_window.geometry("800x400+400+86")
my_window.config(bg="#EED5B7")
my_window.title("How To Resize Image")
my_window.geometry("800x400+400+86")
my_window.config(bg="#EED5B7")
OpenImage = Image.open("E:\Python Work\love3.png") #Open Image
newImage = ImageTk.PhotoImage(OpenImage) # Convert Image Into PhotoImage
newImage = ImageTk.PhotoImage(OpenImage) # Convert Image Into PhotoImage
lbl1= Label(my_window, image=newImage) #newImage set in Label
lbl1.pack(pady=30)
lbl1.pack(pady=30)
my_window.mainloop()
Write Down Code Your Code Editor. To show Your Output. If Use Pycharm Press Shift+F10 and Show Your Output.
If You Want to Resize Image Just Follow Like This....
Example 2:
from tkinter import *
from PIL import ImageTk, Image
my_window = Tk()
my_window.title("How To Resize Image")
my_window.geometry("800x400+400+86")
my_window.config(bg="#EED5B7")
OpenImage = Image.open("E:\Python Work\love3.png") #Open Image
resizeimage =OpenImage.resize((500,375), Image.ANTIALIAS) # Using Resize fucntion Resize Image
newImage = ImageTk.PhotoImage(resizeimage) #Convert Image to Photoimage
lbl1= Label(my_window, image=newImage) #newImage set in Label
lbl1.pack(pady=30)
my_window.mainloop()
from PIL import ImageTk, Image
my_window.title("How To Resize Image")
my_window.geometry("800x400+400+86")
my_window.config(bg="#EED5B7")
resizeimage =OpenImage.resize((500,375), Image.ANTIALIAS) # Using Resize fucntion Resize Image
newImage = ImageTk.PhotoImage(resizeimage) #Convert Image to Photoimage
lbl1.pack(pady=30)
Post a Comment