def create_placeholder_img(width=None, height=None, placeholder_reason=None):
    if width is None and height is None:
        raise exc.MissingDimensionsError("Specify at least one of `width` "
                                         "or `height`")
    placeholder_width = width or height
    placeholder_height = height or width
    placeholder_text = '{}x{}'.format(placeholder_width,
                                      placeholder_height)
    if placeholder_reason is not None:
        placeholder_text += u' ({})'.format(placeholder_reason)
    text_fill = (255, ) * 3
    bg_fill = (220, ) * 3
    img = Image.new('RGB', (placeholder_width, placeholder_height), bg_fill)
    draw = ImageDraw.Draw(img)
    font = ImageFont.truetype(_get_package_path('DroidSans.ttf'), size=36)
    text_width, text_height = draw.textsize(placeholder_text, font=font)
    draw.text((((placeholder_width - text_width) / 2),
               ((placeholder_height - text_height) / 2)),
              text=placeholder_text, font=font, fill=text_fill)
    del draw
    return img
Create a placeholder image that specified its width and height, and an optional text.
dataset/ETHPy150Open jmagnusson/Flask-Resize/flask_resize/__init__.py/create_placeholder_img