compress png

master
bakatrouble 10 months ago
parent 572db1d384
commit b2b727597b

@ -38,8 +38,8 @@ class StickersBotModuleConfig(TelegramBotModuleConfig):
else:
target_height = 512
im = im.resize((target_width, target_height), Image.ANTIALIAS)
with tempfile.NamedTemporaryFile(suffix='.webp') as f:
im.save(f, 'webp')
with tempfile.NamedTemporaryFile(suffix='.png') as f:
im.quantize(method=2).save(f, 'png')
f.seek(0)
update.message.reply_document(f, caption=f'{width}x{height} -> {target_width}x{target_height}')

Loading…
Cancel
Save