mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-27 14:01:09 +00:00
fix : #259 AttributeError fixed
This commit is contained in:
parent
b652b9f602
commit
f66126186b
|
@ -2,11 +2,18 @@ import PIL
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from tkinter.filedialog import *
|
from tkinter.filedialog import *
|
||||||
|
|
||||||
file_path=askopenfilenames()
|
file_paths = askopenfilenames()
|
||||||
img = PIL.Image.open(file_path)
|
|
||||||
myHeight,myWidth = img.size
|
|
||||||
|
|
||||||
img=img.resize((myHeight,myWidth),Image.Resampling.LANCZOS)
|
if len(file_paths) == 0:
|
||||||
save_path=asksaveasfile()
|
print("No Files Selected")
|
||||||
|
|
||||||
img.save(save_path+"_compressed.JPG")
|
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}")
|
Loading…
Reference in New Issue
Block a user