PIL how to scale image in relation to the text drawn on image : <p>I am trying to dynamically increase image size with respect to font and text given to <code>draw.text()</code>. </p>

<p>Orignal Problem is to create signature image based on name and the font user selects.</p>

<p>Here is my code</p>

<pre><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')
</code></pre>

<p>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 ? </p>

<p><strong>Note</strong>: This question is opposite to <a href="https://stackoverflow.com/questions/4902198/pil-how-to-scale-text-size-in-relation-to-the-size-of-the-image">this stackoverflow question</a></p>
