def is_image_file(filename: str | Path) -> bool:
    """Check if the filename has a valid image extension.

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

    Returns:
        bool: ``True`` if filename has valid image extension

    Examples:
        >>> is_image_file("image.jpg")
        True

        >>> is_image_file("image.png")
        True

        >>> is_image_file("image.txt")
        False
    """
    filename = Path(filename)
    return filename.suffix.lower() in IMG_EXTENSIONS
Check if the filename has a valid image extension.

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

    Returns:
        bool: ``True`` if filename has valid image extension

    Examples:
        >>> is_image_file("image.jpg")
        True

        >>> is_image_file("image.png")
        True

        >>> is_image_file("image.txt")
        False
    
src/anomalib/data/utils/image.py