Update file_util.py

Convert PNG to JPEG compatible
This commit is contained in:
lee.wp14 2018-09-01 01:34:32 +08:00 committed by GitHub
parent 2849de3dc1
commit 2dd2fffffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -14,6 +14,8 @@ def resize_img(file_path, max_size=(640, 640), quality=90):
if img.size[0] > max_size[0] or img.size[1] > max_size[1]: if img.size[0] > max_size[0] or img.size[1] > max_size[1]:
img.thumbnail(max_size, Image.ANTIALIAS) img.thumbnail(max_size, Image.ANTIALIAS)
if (img.format == 'PNG'):
img = img.convert('RGB')
img.save(file_path, quality=quality) img.save(file_path, quality=quality)