diff --git a/main.py b/main.py index 5ccd53c..bd6305e 100644 --- a/main.py +++ b/main.py @@ -65,11 +65,13 @@ async def check_updates(): caption=caption) elif post.file.ext in ('png', 'jpg'): if post.file.size > 10000000: - im = Image.open(file) - im.thumbnail((2048, 2048), Image.LANCZOS) + dl_im = Image.open(file).convert('RGBA') + dl_im.thumbnail((2048, 2048), Image.LANCZOS) + im = Image.new('RGBA', dl_im.size, (255, 255, 255)) + composite = Image.alpha_composite(im, dl_im).convert('RGB') file.truncate(0) - im.save(file, format='JPEG') - im.seek(0) + composite.save(file, format='JPEG') + file.seek(0) await bot.send_photo(int(os.environ['SEND_CHAT']), file, caption=caption)