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, include_raw=False)¶
Get all images of supported filetypes from the selected directory.
- Parameters:
dir – Path to image directory
recursive (
bool) – Recursively get images from subdirectoriesinclude_raw (
bool) – Include RAW image files
- Return type:
list[Path]- Returns:
Paths of supported image files in the directory
- naturtag.utils.image_glob.get_sidecar_path(path)¶
- Return type:
Path
- naturtag.utils.image_glob.get_valid_image_paths(paths_or_uris, recursive=False, include_sidecars=False, create_sidecars=False, include_raw=False)¶
Get all images of supported filetypes from one or more dirs and/or image paths, including URIs.
Notes on sidecar files:
Directly passing a path to a sidecar file is allowed
When passing a path to a file that is not writeable (e.g., RAW images), a sidecar file will be created or updated for it
- Parameters:
paths – Paths or file URIs to images and/or image directories
recursive (
bool) – Recursively get images from subdirectoriesinclude_sidecars (
bool) – Allow loading a sidecar file without an associated imagecreate_sidecars (
bool) – Create a new sidecar file if a non-writeable file path is provided
- 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, include_sidecars=False, include_raw=False)¶
Determine if a path points to a valid image of a supported type
- Return type:
bool
- naturtag.utils.image_glob.is_raw_path(path)¶
Determine if a path points to a RAW image file
- 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