-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (19 loc) · 1.01 KB
/
main.py
File metadata and controls
26 lines (19 loc) · 1.01 KB
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
from argparse import ArgumentParser
from lib import ImageCompressor
def main() -> None:
parser = ArgumentParser(
"Image Compressor",
"Simple script to compress your images"
)
parser.add_argument("-s", "--source", type=str, required=True, help="Source directory")
parser.add_argument("-d", "--destination", type=str, required=True, help="Destination directory")
parser.add_argument("-o", "--optimize", type=bool, help="Optimize images", default=True)
parser.add_argument("-q", "--quality", type=int, help="Images quality", default=90)
parser.add_argument("-w", "--workers", type=int, help="Max workers count", default=4)
args = parser.parse_args()
comp = ImageCompressor(args.source, args.destination, args.optimize, args.quality)
result = comp.compress_images(args.workers)
print(f"{result.count} Image{'s' if result.count > 1 else ''} were compressed in {round(result.time, 2)}"
f" second{'s' if result.time > 1 else ''}")
if __name__ == '__main__':
main()