Skip to content

TiffTags

blanket.TiffTags provides TIFF field type constants, tag descriptions, and enumerated values compatible with Pillow's TiffTags.

from blanket import ExifTags, TiffTags

tag = TiffTags.lookup(274)
assert (tag.name, tag.type, tag.length) == ("Orientation", TiffTags.SHORT, 1)
assert TiffTags.lookup(259).cvt_enum("LZW") == 5
assert TiffTags.lookup(2, ExifTags.IFD.GPSInfo).name == "GPSLatitude"
assert TiffTags.TYPES[TiffTags.SHORT] == "short"

TagInfo is a named tuple with value, name, type, length, and enum fields. cvt_enum(value) translates known names and passes other values through. Length counts values (one for string-like fields); zero means variable length.

TAGS_V2 maps tag numbers to TagInfo; TAGS_V2_GROUPS contains EXIF, GPS, and interoperability IFD tables. lookup(tag, group=None) selects a table, then falls back to the legacy TAGS name. A missing group does not search the top-level typed table. Unknown tags return TagInfo(tag, "unknown") with None type/length and an empty enum dictionary.

TAGS maps numbers to names and (tag, value) pairs to enum names. TYPES is populated immediately, with no codec import required. Field constants are BYTE, ASCII, SHORT, LONG, RATIONAL, SIGNED_BYTE, UNDEFINED, SIGNED_SHORT, SIGNED_LONG, SIGNED_RATIONAL, FLOAT, DOUBLE, IFD, and LONG8.

These tables do not configure Blanket's TIFF codec or add metadata saving. Pillow's backend-specific LIBTIFF_CORE set is not exposed.