TiffTags

final class tifffile.TiffTags

Multidict-like interface to TiffTag instances in TiffPage.

Differences to a regular dict:

  • values are instances of TiffTag.

  • keys are TiffTag.code (int).

  • multiple values can be stored per key.

  • can be indexed by TiffTag.name (str), slower than by key.

  • iter() returns values instead of keys.

  • values() and items() contain all values sorted by offset.

  • len() returns number of all values.

  • get() takes optional index argument.

  • some functions are not implemented, such as, update and pop.

add(tag, /)

Add tag.

Parameters:

tag (TiffTag)

Return type:

None

keys()

Return codes of all tags.

Return type:

list[int]

values()

Return all tags in order they are stored in file.

Return type:

list[TiffTag]

items()

Return all (code, tag) pairs in order tags are stored in file.

Return type:

list[tuple[int, TiffTag]]

valueof(key, /, default=None, index=None)

Return value of tag by code or name if exists, else default.

Parameters:
  • key (int | str) – Code or name of tag to return.

  • default (Any) – Another value to return if specified tag is corrupted or not found.

  • index (int | None) – Specifies tag in case of multiple tags with identical code. The default is the first tag.

Return type:

Any

get(key, /, default=None, index=None)

Return tag by code or name if exists, else default.

Parameters:
  • key (int | str) – Code or name of tag to return.

  • default (TiffTag | None) – Another tag to return if specified tag is corrupted or not found.

  • index (int | None) – Specifies tag in case of multiple tags with identical code. The default is the first tag.

Return type:

TiffTag | None

getall(key, /, default=None)

Return list of all tags by code or name if exists, else default.

Parameters:
  • key (int | str) – Code or name of tags to return.

  • default (Any) – Value to return if no tags are found.

Return type:

list[TiffTag] | None