Adding a text to an image in Python
Is there the most popular way of adding a text on an image in Python? I
found a few completely different approaches, this seems to be best, but it
doesn't work:
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
img = Image.open("/full_path/1.jpg")
draw = ImageDraw.Draw(img)
font =
ImageFont.truetype("/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-C.ttf",
16)
draw.text((0, 0),"Sample Text",(255,255,255),font=font)
img.save('/full_path/sample-out.jpg')
After its running, the picture still doesn't have a text on it.
No comments:
Post a Comment