import io
import base64


def _to_base64(image_file: str) -> str:
    """Convert the PNG image to its base64 representation."""
    assert image_file.endswith(".png")
    with io.open(image_file, "rb") as f:
        image_content = base64.b64encode(f.read()).decode("utf-8")
    return "data:image/png;base64," + image_content