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)