def get_image_filename(filename: str | Path) -> Path:
    """Get validated image filename.

    Args:
        filename (str | Path): Path to image file

    Returns:
        Path: Validated path to image file

    Raises:
        FileNotFoundError: If file does not exist
        ValueError: If file is not an image

    Examples:
        >>> get_image_filename("image.jpg")
        PosixPath('image.jpg')

        >>> get_image_filename("missing.jpg")
        Traceback (most recent call last):
            ...
        FileNotFoundError: File not found: missing.jpg

        >>> get_image_filename("text.txt")
        Traceback (most recent call last):
            ...
        ValueError: ``filename`` is not an image file: text.txt
    """
    filename = Path(filename)

    if not filename.exists():
        msg = f"File not found: {filename}"
        raise FileNotFoundError(msg)

    if not is_image_file(filename):
        msg = f"``filename`` is not an image file: {filename}"
        raise ValueError(msg)
    return filename
Get validated image filename.

    Args:
        filename (str | Path): Path to image file

    Returns:
        Path: Validated path to image file

    Raises:
        FileNotFoundError: If file does not exist
        ValueError: If file is not an image

    Examples:
        >>> get_image_filename("image.jpg")
        PosixPath('image.jpg')

        >>> get_image_filename("missing.jpg")
        Traceback (most recent call last):
            ...
        FileNotFoundError: File not found: missing.jpg

        >>> get_image_filename("text.txt")
        Traceback (most recent call last):
            ...
        ValueError: ``filename`` is not an image file: text.txt
    
src/anomalib/data/utils/image.py