def generate_image(inpath, outpath, width=None, height=None, format=JPEG,
                   fill=False, upscale=True, anchor=None, quality=80,
                   bgcolor=None, progressive=True, placeholder_reason=None):
    if anchor:
        warnings.warn(
            "anchor has been deprecated in Flask-Resize 0.6 and doesn't do anything to the image. Will be removed in 1.0.",
            DeprecationWarning
        )

    _mkdir_p(outpath.rpartition('/')[0])
    if not os.path.isfile(inpath):
        if placeholder_reason:
            img = create_placeholder_img(width, height, placeholder_reason)
        else:
            raise exc.ImageNotFoundError(inpath)
    else:
        img = Image.open(inpath)
    processor_kwargs = dict(width=width, height=height, upscale=upscale)

    if fill:
        if bgcolor:
            mat_color = ImageColor.getrgb(parse_rgb(bgcolor))
        elif format == JPEG:
            mat_color = (255, 255, 255, 255)  # White
        else:
            mat_color = (0, 0, 0, 0)  # Transparent
        processor_kwargs['mat_color'] = mat_color  # Transparent

    processor = ResizeToFit(**processor_kwargs)
    img = processor.process(img)

    assert (not os.path.exists(outpath)), 'Path to save to already exists'

    options = {}
    if format == JPEG:
        options.update({'quality': int(quality), 'progressive': progressive})

    if bgcolor is not None:
        img = make_opaque(img, bgcolor)

    with open(outpath, 'wb') as outfile:
        save_image(img, outfile, format=format, options=options)
    return img
Load frame-relation element and its child fe-relation elements from frRelation.xml.
dataset/ETHPy150Open jmagnusson/Flask-Resize/flask_resize/__init__.py/generate_image--crossover with--dataset/ETHPy150Open nltk/nltk/nltk/corpus/reader/framenet.py/FramenetCorpusReader._handle_framerelationtype_elt