In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [2]:
#https://stackoverflow.com/questions/24085996/how-i-can-load-a-font-file-with-pil-imagefont-truetype-without-specifying-the-ab
#font = ImageFont.truetype("/usr/share/fonts/truetype/freefont/FreeMono.ttf", 28, encoding="unic")
ff = '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
In [3]:
from PIL import Image, ImageFont, ImageDraw, ImageEnhance

#source_img = Image.open(file_name).convert("RGBA")
font = ImageFont.truetype(ff, 60)

#draw = ImageDraw.Draw(source_img)
img = Image.new("RGB", (1200,300), (0,0,0))
draw = ImageDraw.Draw(img)
draw.rectangle(((1, 1), (1199, 299)), fill="white", outline='black', width=0)
draw.text((400, 110), "<not found>", "black", font=font)
#draw.text((20, 70), "something123", font=ImageFont.truetype("font_path123"))

#source_img.save(out_file, "JPEG")
display(img)
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: