azils3/bash
0
1# Ultroid - UserBot2# Copyright (C) 2021-2025 TeamUltroid3#4# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >5# PLease read the GNU Affero General Public License in6# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.7"""8✘ Commands Available -9 10•`{i}size <reply to media>`11 To get size of it.12 13•`{i}resize <number> <number>`14 To resize image on x, y axis.15 eg. `{i}resize 690 960`16"""17from PIL import Image18 19from . import HNDLR, eor, get_string, os, ultroid_cmd20 21 22@ultroid_cmd(pattern="size$")23async def size(e):24 r = await e.get_reply_message()25 if not (r and r.media):26 return await e.eor(get_string("ascii_1"))27 k = await e.eor(get_string("com_1"))28 if hasattr(r.media, "document"):29 img = await e.client.download_media(r, thumb=-1)30 else:31 img = await r.download_media()32 im = Image.open(img)33 x, y = im.size34 await k.edit(f"Dimension Of This Image Is\n`{x} x {y}`")35 os.remove(img)36 37 38@ultroid_cmd(pattern="resize( (.*)|$)")39async def resize(e):40 r = await e.get_reply_message()41 if not (r and r.media):42 return await e.eor(get_string("ascii_1"))43 sz = e.pattern_match.group(1).strip()44 if not sz:45 return await eor(46 f"Give Some Size To Resize, Like `{HNDLR}resize 720 1080` ", time=547 )48 k = await e.eor(get_string("com_1"))49 if hasattr(r.media, "document"):50 img = await e.client.download_media(r, thumb=-1)51 else:52 img = await r.download_media()53 sz = sz.split()54 if len(sz) != 2:55 return await eor(56 k, f"Give Some Size To Resize, Like `{HNDLR}resize 720 1080` ", time=557 )58 x, y = int(sz[0]), int(sz[1])59 im = Image.open(img)60 ok = im.resize((x, y))61 ok.save(img, format="PNG", optimize=True)62 await e.reply(file=img)63 os.remove(img)64 await k.delete()65 