diff --git a/Image_Compressor/Image_Compressor.py b/Image_Compressor/Image_Compressor.py index b838e22..5704c8d 100644 --- a/Image_Compressor/Image_Compressor.py +++ b/Image_Compressor/Image_Compressor.py @@ -2,11 +2,18 @@ import PIL from PIL import Image from tkinter.filedialog import * -file_path=askopenfilenames() -img = PIL.Image.open(file_path) -myHeight,myWidth = img.size +file_paths = askopenfilenames() -img=img.resize((myHeight,myWidth),PIL.Image.ANTILIAS) -save_path=asksaveasfile() +if len(file_paths) == 0: + print("No Files Selected") -img.save(save_path+"_compressed.JPG") \ No newline at end of file +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}") \ No newline at end of file diff --git a/Image_Compressor/README.md b/Image_Compressor/README.md index 82db271..9eb1440 100644 --- a/Image_Compressor/README.md +++ b/Image_Compressor/README.md @@ -7,5 +7,7 @@ It automates the task of compressing the image in day to day lives. # Dependencies: - pip install image +Note : Use python3.11 for tkinder + + `pip install pillow`