ehsan-dashboards/dashboards/VPN_chanel/test_pillow.py

20 lines
887 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from PIL import Image, ImageDraw, ImageFont
import arabic_reshaper
from bidi.algorithm import get_display
img = Image.new('RGB', (1080, 1080), '#0F172A')
draw = ImageDraw.Draw(img)
font_path = '/workspace/personal/dashboards/VPN_chanel/backend/app/static/fonts/Vazirmatn-Bold.ttf'
font_title = ImageFont.truetype(font_path, 48)
font_price = ImageFont.truetype(font_path, 36)
text_farsi = get_display(arabic_reshaper.reshape("ارتقای لول کارها با Google Gemini Pro"))
price_farsi = get_display(arabic_reshaper.reshape("تخفیف ویژه: ۶۰۰,۰۰۰ تومان"))
draw.text((540, 200), text_farsi, font=font_title, fill='#FFFFFF', anchor='mm')
draw.rounded_rectangle([290, 500, 790, 590], radius=45, fill='#F59E0B')
draw.text((540, 545), price_farsi, font=font_price, fill='#000000', anchor='mm')
img.save('/tmp/test_pillow_farsi.png')
print("Saved pillow image")