Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pyrogram import filters
- from wbb import app
- from PIL import Image, ImageDraw, ImageFont
- import emoji
- import io
- from wbb.core.decorators.errors import capture_err
- @app.on_message(filters.command("add"))
- async def add_emoji(_, message):
- if not message.reply_to_message or not message.reply_to_message.photo:
- await message.reply("Please reply to a photo to add an emoji.")
- return
- photo_data = await message.reply_to_message.download(in_memory=True)
- image = Image.open(photo_data).convert('RGB')
- emoji_text = emoji.emojize(":zipper-mouth_face:")
- font_size = 109
- unicode_font = ImageFont.truetype("NotoColorEmoji.ttf", font_size, layout_engine=ImageFont.Layout.RAQM)
- draw = ImageDraw.Draw(image, 'RGB')
- draw.text((20, 20), emoji_text, font=unicode_font, embedded_color=True)
- photo_data = io.BytesIO()
- photo_data.name = 'output_image.jpg'
- image.save(photo_data)
- await app.send_photo(message.chat.id, photo=photo_data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement