From 0947a81e7ae1dc2ff986a1e116541098d65ebbb3 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Wed, 1 Jun 2022 00:10:53 +0300 Subject: sound_bot: support rotating captured photos --- src/sound_bot.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/sound_bot.py') diff --git a/src/sound_bot.py b/src/sound_bot.py index 833f5c2..dc9b2c1 100755 --- a/src/sound_bot.py +++ b/src/sound_bot.py @@ -26,6 +26,8 @@ from telegram.ext import ( MessageHandler ) +from PIL import Image + logger = logging.getLogger(__name__) RenderedContent = tuple[str, Optional[InlineKeyboardMarkup]] record_client: Optional[RecordClient] = None @@ -452,6 +454,13 @@ def camera_capture(ctx: Context) -> None: if flash: client.setflash(False) + camera_config = config['cameras'][cam] + if 'rotate' in camera_config: + im = Image.open(fd.name) + im.rotate(camera_config['rotate'], expand=True) + # im.show() + im.save(fd.name) + try: with open(fd.name, 'rb') as f: bot.send_photo(ctx.user_id, photo=f) -- cgit v1.2.3