From 454629e1c340cbde6f079cea7cbc559a575a405e Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Thu, 30 Mar 2023 22:20:36 +0300 Subject: [PATCH] change thumbnail to resize --- main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 380ca24..f061415 100644 --- a/main.py +++ b/main.py @@ -68,7 +68,11 @@ async def check_updates(): if post.file.size > 10000000: logging.warning('compressing') dl_im = Image.open(file).convert('RGBA') - dl_im.thumbnail((1500, 1500), Image.LANCZOS) + if dl_im.size[0] > 2000 or dl_im.size[1] > 2000: + larger_dimension = max(dl_im.size) + ratio = 2000 / larger_dimension + dl_im = dl_im.resize((int(dl_im.size[0] * ratio), int(dl_im.size[1] * ratio)), + Image.LANCZOS) im = Image.new('RGBA', dl_im.size, (255, 255, 255)) composite = Image.alpha_composite(im, dl_im).convert('RGB') file.truncate(0)