title: python PIL draw.text
body: <p>I was following this post: <a href="https://haptik.ai/tech/putting-text-on-images-using-python-part2/" rel="nofollow noreferrer">https://haptik.ai/tech/putting-text-on-images-using-python-part2/</a>
  However, every time I try to execute the example code:</p>
  
  <pre><code>text = "This could be a single line text but its too long to fit in one."
  lines = text_wrap(text, font, image_size[0])
  line_height = font.getsize('hg')[1]
  
  x = 10
  y = 20
  for line in lines:
      # draw the line on the image
      draw.text((x, y), line, fill=color, font=font)
      # update the y position so that we can use it for next line
      y = y + line_height
  # save the image
  img.save('word2.png', optimize=True)
  </code></pre>
  
  <p>I get an error that name 'draw' is not defined on this line:</p>
  
  <pre><code>draw.text((x, y), line, fill=color, font=font)
  </code></pre>
  
  <p>I tried to change it to:</p>
  
  <pre><code>ImageDraw.Draw.text((x, y), line, fill=color, font=font)
  </code></pre>
  
  <p>as that what I believe the documentation specifies: <a href="https://pillow.readthedocs.io/en/4.1.x/reference/ImageDraw.html" rel="nofollow noreferrer">https://pillow.readthedocs.io/en/4.1.x/reference/ImageDraw.html</a></p>
  
  <p>However, that did not work either.
  So could someone help fix this error, because I'm not quite sure what's wrong. 
  I'm using python 3 in VS Code if that's of any help</p>
  
  <p>Thanks in advance :)</p>