get_image_paths
- lib.utils.get_image_paths(directory: str, extension: str | None = None) list[str]
Gets the image paths from a given directory.
The function searches for files with the specified extension(s) in the given directory, and returns a list of their paths. If no extension is provided, the function will search for files with any of the following extensions: ‘.bmp’, ‘.jpeg’, ‘.jpg’, ‘.png’, ‘.tif’, ‘.tiff’
- Parameters:
directory (str) – The directory to search in
extension (str | None) – The file extension to search for. If not provided, all image file types will be searched for
- Return type:
The list of full paths to the images contained within the given folder
Example
>>> from lib.utils import get_image_paths >>> get_image_paths('/path/to/directory') ['/path/to/directory/image1.jpg', '/path/to/directory/image2.png'] >>> get_image_paths('/path/to/directory', '.jpg') ['/path/to/directory/image1.jpg']