Created
January 14, 2020 18:03
-
-
Save sagorbrur/be3e9344bde3634b215867610aea1b44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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