naturtag.utils.image_glob module#

Utilities for finding and resolving image paths from directories, URIs, and/or glob patterns

naturtag.utils.image_glob.get_images_from_dir(path, recursive=False)#

Get all images of supported filetypes from the selected directory.

Parameters
  • dir – Path to image directory

  • recursive (bool) – Recursively get images from subdirectories

Return type

list[Path]

Returns

Paths of supported image files in the directory

naturtag.utils.image_glob.get_valid_image_paths(paths_or_uris, recursive=False)#

Get all images of supported filetypes from one or more dirs and/or image paths, including URIs.

Parameters
  • paths – Paths or file URIs to images and/or image directories

  • recursive (bool) – Recursively get images from subdirectories

Return type

set[Path]

Returns

Combined list of image file paths

naturtag.utils.image_glob.glob_paths(path_patterns)#

Given one to many glob patterns, expand all into a list of matching files

Parameters

path_patterns (Iterable[Union[Path, str]]) – Glob patterns

Return type

list[Path]

Returns

Expanded list of file paths

naturtag.utils.image_glob.is_image_path(path)#

Determine if a path points to a valid image of a supported type

Return type

bool

naturtag.utils.image_glob.uri_to_path(path_or_uri)#

Translate a Path, string, or file URI to a Path. Handles urlencoded and Windows paths

Return type

Path