def postprocess_image(
    value: np.ndarray | PIL.Image.Image | str | Path | None,
    cache_dir: str,
    format: str,
) -> ImageData | None:
    """
    Parameters:
        value: Expects a `numpy.array`, `PIL.Image`, or `str` or `pathlib.Path` filepath to an image which is displayed.
    Returns:
        Returns the image as a `FileData` object.
    """
    if value is None:
        return None
    if isinstance(value, str) and value.lower().endswith(".svg"):
        svg_content = extract_svg_content(value)
        return ImageData(
            orig_name=Path(value).name,
            url=f"data:image/svg+xml,{quote(svg_content)}",
        )

    saved = save_image(value, cache_dir=cache_dir, format=format)
    orig_name = Path(saved).name if Path(saved).exists() else None
    return ImageData(path=saved, orig_name=orig_name)

    Parameters:
        value: Expects a `numpy.array`, `PIL.Image`, or `str` or `pathlib.Path` filepath to an image which is displayed.
    Returns:
        Returns the image as a `FileData` object.
    
gradio/image_utils.py