Advertisement
disk6969

Untitled

Jan 13th, 2024
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. from pyrogram import filters
  2. from wbb import app
  3. from PIL import Image, ImageDraw, ImageFont
  4. import emoji
  5. import io
  6. from wbb.core.decorators.errors import capture_err
  7.  
  8. @app.on_message(filters.command("add"))
  9. async def add_emoji(_, message):
  10.     if not message.reply_to_message or not message.reply_to_message.photo:
  11.         await message.reply("Please reply to a photo to add an emoji.")
  12.         return
  13.     photo_data = await message.reply_to_message.download(in_memory=True)
  14.     image = Image.open(photo_data).convert('RGB')
  15.     emoji_text = emoji.emojize(":zipper-mouth_face:")
  16.     font_size = 109
  17.     unicode_font = ImageFont.truetype("NotoColorEmoji.ttf", font_size, layout_engine=ImageFont.Layout.RAQM)
  18.     draw = ImageDraw.Draw(image, 'RGB')
  19.     draw.text((20, 20), emoji_text, font=unicode_font, embedded_color=True)
  20.  
  21.     photo_data = io.BytesIO()
  22.     photo_data.name = 'output_image.jpg'
  23.     image.save(photo_data)
  24.     await app.send_photo(message.chat.id, photo=photo_data)
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement