Add --quality arg to resize.py.

This commit is contained in:
voussoir 2021-03-13 20:32:43 -08:00
parent 12d30a88de
commit eae98ec161
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -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)