Skip to content

Instantly share code, notes, and snippets.

@sagorbrur
Created January 14, 2020 18:03
Show Gist options
  • Save sagorbrur/be3e9344bde3634b215867610aea1b44 to your computer and use it in GitHub Desktop.
Save sagorbrur/be3e9344bde3634b215867610aea1b44 to your computer and use it in GitHub Desktop.
"""
Dependencies:
$sudo apt-get install libfreetype6-dev libharfbuzz-dev libfribidi-dev gtk-doc-tools
$git clone https://github.com/python-pillow/Pillow.git
$cd Pillow/depends
$chmod +x install_raqm.sh
$./install_raqm.sh
$pip install pillow
"""
import numpy as np
from PIL import ImageFont, ImageDraw, Image
import cv2
import time
## Make canvas and set the color
img = np.zeros((200,400,3),np.uint8)
b,g,r,a = 0,255,0,0
## Use bengali font to write bengali.
fontpath = "./Siyamrupali.ttf"
font = ImageFont.truetype(fontpath, 32)
img_pil = Image.fromarray(img)
draw = ImageDraw.Draw(img_pil)
draw.text((50, 80), u"দৃষ্টিভঙ্গি", font = font, fill = (b, g, r, a))
img = np.array(img_pil)
cv2.imwrite("res1.png", img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment