def get_image_filenames(path: str | Path, base_dir: str | Path | None = None) -> list[Path]:
    """Get list of image filenames from path.

    Args:
        path (str | Path): Path to image file or directory
        base_dir (str | Path | None): Base directory to restrict file access

    Returns:
        list[Path]: List of paths to image files

    Examples:
        >>> get_image_filenames("image.jpg")
        [PosixPath('image.jpg')]

        >>> get_image_filenames("images/")
        [PosixPath('images/001.jpg'), PosixPath('images/002.png')]

        >>> get_image_filenames("images/", base_dir="allowed/")
        Traceback (most recent call last):
            ...
        ValueError: Access denied: Path is outside the allowed directory
    """
    path = validate_path(path, base_dir)
    image_filenames: list[Path] = []

    if path.is_file():
        image_filenames = [get_image_filename(path)]
    elif path.is_dir():
        image_filenames = get_image_filenames_from_dir(path)
    else:
        msg = "Path is not a file or directory"
        raise FileNotFoundError(msg)

    return image_filenames
Get list of image filenames from path.

    Args:
        path (str | Path): Path to image file or directory
        base_dir (str | Path | None): Base directory to restrict file access

    Returns:
        list[Path]: List of paths to image files

    Examples:
        >>> get_image_filenames("image.jpg")
        [PosixPath('image.jpg')]

        >>> get_image_filenames("images/")
        [PosixPath('images/001.jpg'), PosixPath('images/002.png')]

        >>> get_image_filenames("images/", base_dir="allowed/")
        Traceback (most recent call last):
            ...
        ValueError: Access denied: Path is outside the allowed directory
    
src/anomalib/data/utils/image.py