From eae98ec161b8d80a7e60d82cbc131cb3c00c16c7 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 13 Mar 2021 20:32:43 -0800 Subject: [PATCH] Add --quality arg to resize.py. --- resize.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resize.py b/resize.py index 89272cf..83b61be 100644 --- a/resize.py +++ b/resize.py @@ -16,6 +16,7 @@ def resize( nearest_neighbor=False, only_shrink=False, scale=None, + quality=100, ): file = pathclass.Path(filename) i = Image.open(file.absolute_path) @@ -62,7 +63,7 @@ def resize( if new_name.extension == '.jpg': i = i.convert('RGB') - i.save(new_name.absolute_path, quality=100) + i.save(new_name.absolute_path, quality=quality) def resize_argparse(args): @@ -76,6 +77,7 @@ def resize_argparse(args): nearest_neighbor=args.nearest_neighbor, only_shrink=args.only_shrink, scale=args.scale, + quality=args.quality, ) def main(argv): @@ -88,6 +90,7 @@ def main(argv): parser.add_argument('--nearest', dest='nearest_neighbor', action='store_true') parser.add_argument('--only_shrink', '--only-shrink', action='store_true') parser.add_argument('--scale', type=float, default=None) + parser.add_argument('--quality', type=int, default=100) parser.set_defaults(func=resize_argparse) args = parser.parse_args(argv)