-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.py
More file actions
29 lines (21 loc) · 746 Bytes
/
Copy pathApp.py
File metadata and controls
29 lines (21 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os, sys
from PIL import Image
class App():
def __init__(self):
ImagePath = sys.argv[1]
if self.ImageCheck(ImagePath):
self.Convert(ImagePath)
def ImageCheck(self, Path: str):
AllowedExtensions = [".png", ".jpg", ".ico"]
for FileExt in AllowedExtensions:
if str.find(Path, FileExt):
return True
return False
def Convert(self, Path: str):
SIZES = [256, 128, 48, 32, 16]
ImageMem = Image.open(Path)
for Size in SIZES:
Saveable = ImageMem.resize((Size, Size))
Saveable.save(f"{os.path.basename(Path)}_{Size}_x_{Size}.png")
if __name__ == "__main__":
App()