Exemple #1
0
def placeholder(width,
                height=None,
                bgd="cccccc",
                fgd="909090",
                alphabgd=255,
                alphafgd=255):
    """This endpoint generates the placeholder itself, based on arguments.
    If the height is missing, just make the image square.
    """
    # processing image
    args = {
        "width": width,
        "height": height or width,
        "background_color": bgd,
        "alpha_background": alphabgd,
        "foreground_color": fgd,
        "alpha_foreground": alphafgd,
        "text": request.args.get('text'),
        "font_name": request.args.get('font'),
        "font_size": request.args.get('font_size'),
        "retina": "retina" in request.args
    }
    image = FakeImg(**args)
    response = make_response(
        send_file(image.raw, mimetype='image/png', add_etags=False))
    response.headers['Access-Control-Allow-Origin'] = '*'
    return response
Exemple #2
0
def placeholder(width, height=None, bgd="cccccc", fgd="909090"):
    """This endpoint generates the placeholder itself, based on arguments.
    If the height is missing, just make the image square.
    """
    # processing image
    args = {
        "width": width,
        "height": height or width,
        "background_color": bgd,
        "foreground_color": fgd,
        "text": request.args.get('text'),
        "font_name": request.args.get('font'),
        "font_size": request.args.get('font_size'),
        "retina": "retina" in request.args
    }
    image = FakeImg(**args)
    # return static file
    return send_file(image.raw, mimetype='image/png')