#https://www.youtube.com/watch?v=3RVnDX8cO4s&list=PL1H1sBF1VAKXCayO4KZqSmym2Z_sn6Pha&index=5
from tkinter import *
from PIL import ImageTk, Image
win = Tk()
win.title("Converting images")
win.geometry("600x510+50+50")
file1 = "..\\Images\\Originals\\Elephant.png"
img1 = Image.open(file1)
def Select(e):
global select
selected = lbox.curselection()
select = lbox.get(selected)
img = Image.open("..\\Images\\Originals\\Elephant.png")
if select == "Normal":
imgConv = img.convert(None)
elif select == "Grayscale":
imgConv = img.convert("L")
elif select == "Dither":
imgConv = img.convert("1")
imgConv.save("..\\Images\\Modified\\ElephantConvert.png")
pic = PhotoImage(file="..\\Images\\Modified\\ElephantConvert.png")
lbl1.config(image=pic)
lbl1.image = pic
pic = PhotoImage(file=file1)
lbl1 = Label(win, image=pic)
lbl1.place(x=30, y=60)
lbl1.image = pic
lbox = Listbox(win, height=3, font=("Arial", 11))
lbox.insert(1, "Normal")
lbox.insert(2, "Grayscale")
lbox.insert(3, "Dither")
lbox.place(x=215, y=410)
lbox.bind('<<ListboxSelect>>', Select)
win.mainloop()

No comments:
Post a Comment