I am trying to dynamically increase image size with respect to font and text given to draw.text()
.
Orignal Problem is to create signature image based on name and the font user selects.
Here is my code
from PIL import (Image, ImageDraw, ImageFont,)
width=20
height=20
selected_font='simply_glomrous.ttf'
font_size=30
img = Image.new('RGBA', (width, height), (255, 255, 255, 0))
draw = ImageDraw.Draw(img)
font = ImageFont.truetype(selected_font, font_size)
draw.text((0,0), "Adil Malik", (0,0,0), font)
img.save('signature.png')
But i am still having same image size defined in width and height. Can we do dynamically resizing of image based on font and its size ?
Note: This question is opposite to this stackoverflow question