tagkit.core.registry

Registry of EXIF tags and their metadata.

This module provides the ExifRegistry class which maintains information about all supported EXIF tags, their IDs, names, and types.

Module Contents

Classes

RegistryConfValue

ExifRegistry

Registry of all EXIF tags compatible with tagkit.

Data

API

class tagkit.core.registry.RegistryConfValue

Bases: typing.TypedDict

name: str = None
type: tagkit.core.types.ExifType = None
tagkit.core.registry.RegistryConfKey = None
tagkit.core.registry.RegistryConf = None
class tagkit.core.registry.ExifRegistry(registry_conf: tagkit.core.registry.RegistryConf)

Registry of all EXIF tags compatible with tagkit.

Args:

registry_conf (RegistryConf): The EXIF tag registry configuration.

Initialization

classmethod from_yaml(path: Union[pathlib.Path, str, None] = None) Self

Load the EXIF tag registry from a YAML file.

Args:

path (Union[Path, str, None]): Path to the YAML file. If None, uses default.

Returns:

ExifRegistry: The loaded registry instance.

Raises:

FileNotFoundError: If the YAML file does not exist. yaml.YAMLError: If the YAML file is invalid.

property tag_names: list[str]

List all tag names in the registry.

Returns:

list[str]: All tag names.

Example:
>>> tag_registry.tag_names[:5]
['ProcessingSoftware', 'NewSubfileType', 'SubfileType', 'ImageWidth', 'ImageLength']
get_ifd(tag_key: Union[int, str], thumbnail: bool = False) tagkit.core.types.IfdName

Get the IFD (Image File Directory) for a tag. If a tag id is provided that is present in multiple IFDs, a warning is raised and the first found IFD is returned. IFD’s are searched in the order of IFD0, Exif, GPS, Interop. If the thumbnail argument is True, IFD1 is always returned.

Args:

tag_key (Union[int, str]): Tag name or tag ID. thumbnail (bool): If True, return the thumbnail IFD (IFD1).

Returns:

IfdName: The IFD name.

Raises:

ValueError: If the tag or IFD is invalid.

Example:
>>> tag_registry.get_ifd('Make')
'IFD0'
resolve_tag_id(tag_key: Union[int, str]) int

Get tag ID for a given tag name or return the ID unchanged if already an int.

Args:

tag_key (Union[int, str]): Tag name or tag ID.

Returns:

int: Tag ID for the given tag name.

Raises:

InvalidTagName: If the tag name is invalid. InvalidTagId: If the tag ID is invalid.

Example:
>>> tag_registry.resolve_tag_id('Make')
271
resolve_tag_name(tag_key: Union[int, str], ifd: Optional[tagkit.core.types.IfdName] = None) str

Get tag name for a given tag name or tag ID. If given a tag ID, returns the name.

Args:

tag_key (Union[int, str]): Tag name or tag ID. ifd (Optional[IfdName]): Specific IFD to use.

Returns:

str: Tag name for the given tag ID.

Raises:

InvalidTagName: If the tag name is invalid. InvalidTagId: If the tag ID is invalid. ValueError: If the tag or IFD is invalid.

Example:
>>> tag_registry.resolve_tag_name(271)
'Make'
_validate_tag_key(tag_key: Union[int, str]) None

Validate the tag key (either ID or name).

Args:

tag_key (Union[int, str]): Tag name or tag ID.

Raises:

InvalidTagName: If the tag name is invalid. InvalidTagId: If the tag ID is invalid.

_validate_tag_id(tag_id: int) None
_validate_tag_name(tag_name: str) None
get_exif_type(tag_key: Union[int, str]) tagkit.core.types.ExifType

Get the EXIF type for a tag.

Args:

tag_key (Union[int, str]): Tag name or tag ID.

Returns:

ExifType: The EXIF type for the tag.

Raises:

InvalidTagName: If the tag name is invalid. InvalidTagId: If the tag ID is invalid.

Example:
>>> tag_registry.get_exif_type('Make')
'ASCII'
tagkit.core.registry.tag_registry = 'from_yaml(...)'