oooxx

Photo

Feb 5th, 2022
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. #coder : ExEc @vnvn6 Warrior
  2. try:
  3.     import PIL
  4.     from PIL import Image
  5.     from tkinter import *
  6.     from tkinter.filedialog import *
  7. except:
  8.     os.system("pip install PIL")    
  9.  
  10. def ImageCopressor():
  11.     file_path = askopenfilename()
  12.     img = PIL.Image.open(file_path)
  13.     myheight, mywidth = img.size
  14.     img = img.resize((myheight, mywidth), PIL.Image.ANTIALIAS)
  15.     save_path = asksaveasfilename()
  16.     img.save(save_path + "Comp.jpg", quality = 50)
  17. root = Tk()
  18. root.title("Image Copressor Warrior")
  19. root.geometry("300x300")
  20.  
  21.  
  22. Button(root, text="Select Image", font=('Helvetic 16 bold'),
  23.     bg="blue",
  24.     fg="white",
  25.     command= ImageCopressor
  26. ).place(relx=.5, rely=.5, anchor=CENTER)
  27.  
  28.  
  29. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment