2021-06-02 12:48:12 +00:00
|
|
|
import PIL
|
|
|
|
from PIL import Image
|
|
|
|
from tkinter.filedialog import *
|
|
|
|
|
2023-09-29 10:46:07 +00:00
|
|
|
file_paths = askopenfilenames()
|
2021-06-02 12:48:12 +00:00
|
|
|
|
2023-09-29 10:46:07 +00:00
|
|
|
if len(file_paths) == 0:
|
|
|
|
print("No Files Selected")
|
2021-06-02 12:48:12 +00:00
|
|
|
|
2023-09-29 10:46:07 +00:00
|
|
|
for file in file_paths:
|
|
|
|
file_name = file.split('/')[-1]
|
|
|
|
file_name, extension = file_name.split('.')
|
|
|
|
|
|
|
|
img = PIL.Image.open(file)
|
|
|
|
height,width = img.size
|
|
|
|
img=img.resize((height,width),Image.Resampling.LANCZOS)
|
|
|
|
|
|
|
|
save_path=askdirectory()
|
|
|
|
img.save(save_path+f"/{file_name}_compressed.{extension}")
|