diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-06-01 00:10:53 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-06-01 00:10:53 +0300 |
commit | 0947a81e7ae1dc2ff986a1e116541098d65ebbb3 (patch) | |
tree | 84a7f5b240e87fee3a6e1c5ac0e059825002119a /src/sound_bot.py | |
parent | 4418040f2d9d8f7a4afabb22df80e6e339a8673e (diff) |
sound_bot: support rotating captured photos
Diffstat (limited to 'src/sound_bot.py')
-rwxr-xr-x | src/sound_bot.py | 9 |
1 files changed, 9 insertions, 0 deletions
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) |