TIFF (Tagged Image File Format)
| Full name | Tagged Image File Format |
|---|---|
| Extensions | .tif, .tiff |
| MIME type | image/tiff |
| Type | raster image, uncompressed or lossless / lossy compression, multi-page |
| Starts with | 49 49 2A 00 (II*\0, little-endian) or 4D 4D 00 2A (MM\0*, big-endian); BigTIFF: 49 49 2B 00 or 4D 4D 00 2B |
| Specification | TIFF Revision 6.0 |
| Maintained by | Adobe (TIFF 6.0 is not updated; extensions like BigTIFF and GeoTIFF are maintained by the community and OGC) |
| License | open; the LZW patents expired in 2003-2004 |
TIFF is a container for raster images built around a list of numbered tags. A tag can describe the size, the pixel format, the compression, the resolution, the color profile or the location of the pixel data. That makes TIFF very flexible: it stores 1-bit fax scans, 8-bit and 16-bit RGB photos, CMYK for print, 32-bit floating point data and images with many channels. One file can hold many pages.
TIFF is used for scanning and document imaging, fax, print and prepress, photo archives (lossless masters), microscopy and medical imaging, and geospatial data (GeoTIFF, Cloud Optimized GeoTIFF). Web browsers don’t display TIFF, except Safari.
When to use TIFF#
- Use for lossless master copies of photos and scans, especially at 16 bits per channel or in CMYK.
- Use for multi-page scanned documents and fax (CCITT Group 4 compression gives small 1-bit pages).
- Use for GIS raster data (GeoTIFF / COG) and scientific images with floating point or many channels.
- Avoid on the web: browsers other than Safari don’t show it. Use PNG, JPEG, WebP or AVIF.
- Avoid when you need maximum compatibility for unusual features: many readers support only baseline TIFF (strips, uncompressed, PackBits, LZW, Deflate, JPEG). Tiles, floating point, many channels or BigTIFF break simple readers.
File structure#
A TIFF file has an 8-byte header followed by Image File Directories (IFDs) and pixel data placed anywhere in the file. Offsets point from the header to the first IFD, from each IFD to the next one, and from tags to their data.
49 49 byte order: II = little-endian (MM = big-endian)
2A 00 magic number 42
08 00 00 00 offset of the first IFD: 8
0F 00 IFD: 15 entries
00 01 03 00 01 00 00 00 00 04 00 00 tag 256 ImageWidth, type SHORT, count 1, value 1024
01 01 03 00 01 00 00 00 00 03 00 00 tag 257 ImageLength, type SHORT, count 1, value 768
... 13 more 12-byte entries, sorted by tag number
00 00 00 00 offset of the next IFD (0 = this is the last page)
The byte order mark applies to every number in the file. A reader must handle both orders.
Image File Directory (IFD)#
Each IFD describes one image (page, thumbnail or reduced-resolution version):
| Field | Size | Description |
|---|---|---|
| Count | 2 bytes | number of entries |
| Entries | 12 bytes each | tag, type, count, value or offset |
| Next IFD | 4 bytes | offset of the next IFD, 0 for the last one |
Each 12-byte entry:
| Field | Size | Description |
|---|---|---|
| Tag | 2 bytes | tag number, e.g. 256 ImageWidth |
| Type | 2 bytes | 1 BYTE, 2 ASCII, 3 SHORT, 4 LONG, 5 RATIONAL, 7 UNDEFINED, 11 FLOAT, 12 DOUBLE, and signed variants |
| Count | 4 bytes | number of values (not bytes) |
| Value / offset | 4 bytes | the value itself if it fits in 4 bytes, otherwise the offset of the values |
Entries must be sorted by tag number. Multi-page TIFF is a chain of IFDs. A page can also point to child IFDs with the SubIFDs tag (used for reduced-resolution images and by DNG raw files), and to Exif and GPS IFDs.
Common tags#
| Tag | Name | Purpose |
|---|---|---|
| 254 | NewSubfileType | page, thumbnail (reduced resolution) or transparency mask |
| 256, 257 | ImageWidth, ImageLength | size in pixels |
| 258 | BitsPerSample | bits per channel, e.g. 8,8,8 |
| 259 | Compression | 1 none, 2 CCITT RLE, 3 Group 3, 4 Group 4, 5 LZW, 7 JPEG, 8 Deflate (Adobe), 32773 PackBits, 34887 LERC, 50000 ZSTD, 50001 WebP |
| 262 | PhotometricInterpretation | 0 WhiteIsZero, 1 BlackIsZero, 2 RGB, 3 palette, 4 mask, 5 CMYK, 6 YCbCr, 8 CIELab |
| 273, 279 | StripOffsets, StripByteCounts | where the strips of pixel data are |
| 274 | Orientation | rotation / mirroring, as in Exif |
| 277 | SamplesPerPixel | number of channels |
| 278 | RowsPerStrip | rows in each strip |
| 282, 283, 296 | XResolution, YResolution, ResolutionUnit | DPI |
| 284 | PlanarConfiguration | 1 chunky (RGBRGB), 2 planar (RRR GGG BBB) |
| 305, 306, 315 | Software, DateTime, Artist | text metadata |
| 317 | Predictor | 2 horizontal differencing, 3 floating point; improves LZW / Deflate |
| 320 | ColorMap | palette for photometric 3 |
| 322, 323, 324, 325 | TileWidth, TileLength, TileOffsets, TileByteCounts | tiled layout instead of strips |
| 338 | ExtraSamples | meaning of extra channels, e.g. alpha |
| 339 | SampleFormat | 1 unsigned int, 2 signed int, 3 floating point |
| 700 | XMP | XMP metadata |
| 34665, 34853 | ExifIFD, GPSInfo | offsets of the Exif and GPS IFDs |
| 34675 | ICC Profile | embedded color profile |
The Library of Congress list of TIFF tags covers public and private tags.
Strips and tiles#
Pixel data is split into strips (groups of full rows) or tiles (rectangles, width and height multiples of 16). Each strip or tile is compressed on its own, so a reader can decode part of a large image. Tiles are better for very large images that are panned and zoomed (GIS, microscopy, pyramids); strips are the baseline that every reader supports.
Compression#
| Compression | Kind | Typical use |
|---|---|---|
| None | - | maximum compatibility, fast |
| PackBits | lossless RLE | simple, small gain |
| LZW | lossless | the default in many programs; use with Predictor 2 for photos |
| Deflate (zip) | lossless | usually smaller than LZW |
| ZSTD, LERC | lossless / limited loss | GIS and scientific data (GDAL, libtiff 4.x) |
| CCITT Group 3 / 4 | lossless, 1-bit | fax and black-and-white scans |
| JPEG | lossy | photos, YCbCr; “new style” JPEG (7). Old style (6) is obsolete |
| WebP, JPEG XL | lossy / lossless | newer, supported by libtiff and GDAL only |
BigTIFF#
Classic TIFF uses 32-bit offsets, which limits a file to 4 GB. BigTIFF uses magic number 43, 64-bit offsets and counts, 20-byte IFD entries and 8-byte next-IFD offsets. Its header is 16 bytes: byte order, 43, offset size 8, 0, then an 8-byte offset of the first IFD. Readers need explicit BigTIFF support (libtiff 4.0+, GDAL, tifffile, most current libraries).
GeoTIFF and Cloud Optimized GeoTIFF#
GeoTIFF is a regular TIFF with extra tags that place the image on the earth: ModelPixelScaleTag (33550), ModelTiepointTag (33922), ModelTransformationTag (34264) and GeoKeyDirectoryTag (34735) with the coordinate reference system (e.g. EPSG:4326). Programs that don’t know these tags still show the image.
A Cloud Optimized GeoTIFF (COG) is a tiled GeoTIFF with reduced-resolution overviews and its IFDs at the start of the file, so a client can read only the tiles it needs with HTTP range requests. Create one with gdal_translate in.tif out.tif -of COG.
Variants built on TIFF#
- DNG and most camera raw formats (CR2, NEF, ARW) use the TIFF structure.
- OME-TIFF (microscopy) stores OME-XML metadata in the ImageDescription tag.
- TIFF/EP and TIFF/IT are ISO profiles for photography and prepress.
- TIFF-F / TIFF-FX are profiles for fax.
Inspecting a TIFF file#
tiffinfo file.tif(libtiff tools) prints all tags of every IFD;tiffdumpshows raw entries and offsets.gdalinfo file.tifshows size, bands, compression, coordinate system and overviews.exiftool -v3 file.tifshows tags with offsets and hex values.magick identify -verbose file.tif(ImageMagick) shows every page.
Specifications and documentation#
- TIFF Revision 6.0 (Adobe, 1992): the base specification, still current
- Adobe PageMaker 6.0 TIFF Technical Notes: SubIFDs, new-style JPEG, Deflate clarifications
- BigTIFF design: the 64-bit extension
- OGC GeoTIFF Standard 1.1
- OGC Cloud Optimized GeoTIFF Standard and cogeo.org
- TIFF tags (Library of Congress)
- libtiff documentation
- TIFF at the Library of Congress
- TIFF on Wikipedia
Software that opens TIFF files#
| Software | Windows | macOS | Linux | Web | Can | Notes |
|---|---|---|---|---|---|---|
| SumatraPDF | ✓ | view | free, open source; shows multi-page TIFF as a document | |||
| Microsoft Photos | ✓ | view | built into Windows | |||
| macOS Preview | ✓ | view, edit, convert | built into macOS, multi-page | |||
| GIMP | ✓ | ✓ | ✓ | view, edit, create, convert | free, open source; opens pages as layers | |
| Adobe Photoshop | ✓ | ✓ | view, edit, create, convert | commercial; layers, 16/32-bit, CMYK | ||
| Krita | ✓ | ✓ | ✓ | view, edit, create | free, open source | |
| Paint.NET | ✓ | view, edit, create, convert | free | |||
| IrfanView | ✓ | view, convert | free for non-commercial use; multi-page, fax | |||
| XnView MP | ✓ | ✓ | ✓ | view, convert | free for private use | |
| ImageMagick | ✓ | ✓ | ✓ | convert, create | command line, open source | |
| GDAL | ✓ | ✓ | ✓ | convert, create | command line, open source; GeoTIFF and COG | |
| QGIS | ✓ | ✓ | ✓ | view, edit, create | free, open source GIS; GeoTIFF | |
| Fiji (ImageJ) | ✓ | ✓ | ✓ | view, edit, create, convert | free, open source; scientific and OME-TIFF | |
| Photopea | ✓ | view, edit, create, convert | free, runs in the browser | |||
| Safari | ✓ | view | the only browser that displays TIFF. Also on iOS |
Libraries#
Open-source libraries that read and write TIFF. See all TIFF libraries for a comparison.
| C/C++ | GDAL, libtiff |
|---|---|
| C# | ImageSharp, LibTiff.Net, Magick.NET |
| Java | ImageIO, TwelveMonkeys |
| Go | imaging, x/image/tiff |
| Python | Pillow, rasterio, tifffile |
| Ruby | MiniMagick, ruby-vips |
| Rust | image, tiff |
| PHP | Imagick |