I have figured out how to add text to an Image and this is how I have implemented it.
import docx
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
img = Image.open("a.jpg")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype(<font-file>, <font-size>)
font = ImageFont.truetype("arial.ttf", 16)
draw.text((x, y),"Sample Text",(r,g,b))
draw.text((0, 0),"Sample Text",(255,255,255),font=font)
img.save('C:\\Users\\John\\Desktop\\See\\sample-out.jpg')
From the documentation (draw.text()) i understand it takes position (xy) as the first argument.
How can I pass 3 variables (firstplate, secondplate, thirdplate
) to the text argument and have them dispalyed randomly diagonally (like red) across the Image like below?
Am having great difficulty figuring out how to make the text diagonal, and add them in a loop all across the image.