Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:TIFF

From ReverseEngineering.wiki
Format
Magic 49 49 2A 00 / 4D 4D 00 2A (classic); 49 49 2B 00 / 4D 4D 00 2B (BigTIFF)
Extensions .tif, .tiff
Endianness either (byte-order mark)
On this wiki Facts · Code · Notes · Topics

Tagged Image File Format container: a byte-order mark (II or MM), a version number 42 (classic, 32-bit offsets) or 43 (BigTIFF, 64-bit offsets), and linked image file directories of tagged entries; used as the wrapper for GeoTIFF, Exif and many camera RAW formats.

Overview

A TIFF file starts with a 2-byte byte-order mark: 49 49 ("II", little-endian, 0x4949) or 4D 4D ("MM", big-endian, 0x4d4d), then a 16-bit version number: 42 for classic TIFF and 43 for BigTIFF. The same container is embedded inside JPEG (Exif APP1) and PNG (eXIf), see Format:JPEG and Format:PNG.

Versions and data types

libtiff defines TIFF_VERSION_CLASSIC 42 and TIFF_VERSION_BIG 43. BigTIFF adds the data types LONG8 (16), SLONG8 (17) and IFD8 (18), all 64-bit. Classic data types are BYTE 1, ASCII 2, SHORT 3, LONG 4, RATIONAL 5, SBYTE 6, UNDEFINED 7, SSHORT 8, SLONG 9, SRATIONAL 10, FLOAT 11, DOUBLE 12, IFD 13. See Fact:TIFF/enum/Data types and versions.

Unverified: the BigTIFF header after the version is a 16-bit offset size (8) and a 16-bit zero, followed by an 8-byte offset of the first IFD, and BigTIFF IFD entries are 20 bytes (classic: 12) with an 8-byte entry count. This comes from the BigTIFF design notes the libtiff header points to, not from code read here.

Geographic tags

GeoTIFF stores its georeferencing in private TIFF tags, see Format:GeoTIFF.

Code & repositories

libtiff (the vendored copy inside GDAL was read for the constants).

  • https://github.com/OSGeo/gdal @ 6364d9384bf9936c97f0e50fff179ecd25074f36 · license: MIT (declared by the contributor; GitHub's detector did not recognize LICENSE.TXT)
    GDAL; frmts/gtiff/libtiff/tiff.h is a vendored libtiff header, ogr/ogrsf_frmts/gpkg is the GeoPackage driver
    Tested on: source read, not run: source read only · checked 2026-10-19; last activity 2026-10-17; Note: the latest release ships binaries; the wiki links only the source, never the binaries