import pathlib


def path_to_filename(path, with_suffix=True):
    """Get filename from path.
    
    Parameters
    ==========
    path : str
        Path to retrieve file name from e.g. '/path/to/image.png'.
    with_suffix : bool
        Whether to include the suffix of file path in file name.

    Returns
    =======
    str
        The file name of the path e.g. 'image.png'
        or 'image' if `with_suffix` is false.
    """
    p = pathlib.Path(path)
    if with_suffix:
        return str(p.name)
    else:
        return str(p.with_suffix("").name)