INNER CODE UNIT · Python

load_image_from_file

OpenVGLab/OmniLottie · app.py:625

def load_image_from_file(file_path):

    ext = os.path.splitext(file_path)[1].lower()

    if ext == '.svg':
        import cairosvg
        import io
        png_bytes = cairosvg.svg2png(url=file_path, output_width=448, output_height=448)
        image = PILImage.open(io.BytesIO(png_bytes))
    else:
        image = PILImage.open(file_path)

    if image.mode == 'RGBA':
        image = add_random_background(image)
    else:
        image = image.convert('RGB')

    return image

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…