def image_info(file: Union[File, ImageFile]) -> Image:
    """
    Returns image file information.

    Args:
        file (ImageFile): Image file object.

    Returns:
        Image: Image file information.
    """
    try:
        img = file.as_image_file().read()
    except Exception as exc:
        raise FileError("unable to open image file", file.source, file.path) from exc

    return Image(
        width=img.width,
        height=img.height,
        format=img.format or "",
    )

    Returns image file information.

    Args:
        file (ImageFile): Image file object.

    Returns:
        Image: Image file information.
    
src/datachain/lib/image.py