From cc7d8d0a86ec6436815bbd90052690d6c29602ec Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Thu, 30 Mar 2023 20:53:02 +0300 Subject: [PATCH] fix --- main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 25eab72..06719b6 100644 --- a/main.py +++ b/main.py @@ -64,12 +64,12 @@ async def check_updates(): thumb=post.preview.url, caption=caption) elif post.file.ext in ('png', 'jpg'): - file_resized = BytesIO() - im = Image.open(file) - im.thumbnail((2048, 2048), Image.LANCZOS) - im.save(file_resized, format='JPEG') - im.name = 'file.jpg' - im.seek(0) + if post.file.size > 10000000: + im = Image.open(file) + im.thumbnail((2048, 2048), Image.LANCZOS) + file.truncate(0) + im.save(file, format='JPEG') + im.seek(0) await bot.send_photo(int(os.environ['SEND_CHAT']), file_resized, caption=caption)