def generate(width, height, caption="", bg_color=(100,100,100), text_color=(200,200,200)):
  size = (width,height)       # size of the image to create
  im = Image.new('RGB', size, bg_color) # create the image
  draw = ImageDraw.Draw(im)   # create a drawing object
  DEFAULT_DIM_SIZE = 50
  DEFAULT_CAPTION_SIZE = 30

  text_line_pad = 0

  dim_text = str(width) + u"\u00D7" + str(height) # \u00D7 is multiplication sign

  text_lines = [(dim_text, "ArialBlack.ttf", DEFAULT_DIM_SIZE)]

  if(caption):
    text_lines += [(caption, "Arial.ttf", DEFAULT_CAPTION_SIZE)]

  text_layouts = layout_text(width, height, 0, text_lines)

  for text_layout in text_layouts:
    text, font, pos = text_layout
    draw.text(pos, text, fill=text_color, font=font)

  del draw # I'm done drawing so I don't need this anymore