Tech

Multipage TIFF, LZW Compression and Layers: How It Works

From the outside, a TIFF is just a heavy file with a picture in it. Inside, it's a surprisingly thoughtful machine: eight bytes of header, a card index of "tags," a chain of pages and a handful of lossless compression modes. Let's take it apart — no academic jargon, but no hand-waving either. By the end you'll know why one .tif holds dozens of pages, how LZW shrinks a file while losing nothing, and how BigTIFF differs from the regular kind.

Close-up of circuit boards and chips — a metaphor for the internal structure of the TIFF format
A TIFF is built like a tidy circuit: a header, a directory and data blocks, wired together by addresses. Photo: Pexels

Anatomy of a TIFF: header → IFD → pixels

Every TIFF reads by one simple scheme: a tiny header points to a directory, and the directory points to the pixels. Just three levels — but it's exactly this chain of pointers that makes the format so flexible.

A file opens with an 8-byte header. The first two bytes are the byte order: II (Intel, least-significant byte first) or MM (Motorola, most-significant first). Next comes the "magic number" 42 — a signature that tells a program it's really looking at a TIFF and not something else. The last four bytes of the header are an address: the offset to the first image directory inside the file.

That directory is called an IFD (Image File Directory). Think of it as the table of contents for one image: it holds no pixels itself, but lists what the image is and where its data lives. The IFD is laid out very regularly: first a two-byte count of how many entries it has, then exactly 12 bytes per entry (these are the tags), and right at the end, 4 bytes pointing to the next IFD (or zeros if it's the last one).

The key idea

A TIFF isn't a monolith — it's a kit of blocks tied together by addresses. The header knows where the first IFD is; the IFD knows where the pixels are and where the next IFD is. So data can sit anywhere in the file, in any order — a program still finds it by following the pointers.

Tags: why the format is "tagged"

The T in TIFF stands for Tagged, and that's the whole point. Every property of the image is recorded as a separate tag — a short "property → value" record. Width? A tag. Height? A tag. Compression type, DPI resolution, color model, orientation, bits per channel, the addresses of the pixel data — all of these are separate, numbered tags.

Each tag is exactly 12 bytes and has four parts: the tag number (which property this is), the data type (number, string, fraction), the count of values, and finally the value itself or an address. The clever bit: if the value fits in 4 bytes, it sits right inside the tag; if not, the tag holds an address pointing to where the value is stored elsewhere in the file. That keeps the directory compact and stops long data from bloating it.

This "taggedness" is what makes TIFF nearly immortal. A program reads the tags it knows and quietly skips the ones it doesn't. So a file from the 1990s still opens today, and new capabilities (a new compression type, geographic coordinates, a color profile) are added simply as new tags — old software doesn't understand them, but it doesn't break either.

Header
8 bytes: II/MM + 42 + IFD address
Magic number
42 (0x2A)
One tag
12 bytes
Tags in the spec
70+ standard
Pixel data
strips or tiles
Several pages
chain of IFDs
Color depth
up to 16-bit (and 32-bit float)
BigTIFF threshold
4 GB (32-bit addresses)

Strips and tiles: how pixels are laid out

TIFF doesn't store the pixels as one solid block but split into pieces. That's handier: a program can load just the part of a huge image it needs without reading the whole file, and each piece is compressed independently. There are two ways to split.

  • Strips. The image is cut into horizontal bands — a few rows of pixels each. This is the basic, most common method; any program can open a strip-based TIFF.
  • Tiles. The image is cut into equal-sized rectangular tiles, like a mosaic. This is more efficient for very large images — maps, satellite imagery, scans of hundreds of megapixels: to show a fragment, you only read a few tiles.

The addresses and lengths of these pieces are tags too (one set for strips, another for tiles). From them a program knows exactly where each band or tile sits in the file and how many bytes it takes.

Server racks in a data center — large-file storage and block-based data organization
Laying pixels out in strips and tiles is the same trick as in storage systems: data is easier to read and update in chunks. Photo: Pexels

Multi-page is a chain of IFDs

Now the fun part — how dozens of pages fit into one .tif. The secret is already hidden in the anatomy: remember those 4 bytes at the end of every IFD pointing to the next directory? That's the multi-page mechanism.

Each page is a separate IFD with its own tags and its own pixels. The first page points to the second, the second to the third, and so on. The last IFD holds zeros instead of an address — a signal that says "nothing follows." The result is a singly linked list, like railway cars coupled one to the next.

An important detail: the pages are independent. One can be a color photo scan in LZW, the next a black-and-white page of text in compact CCITT compression, each with its own resolution and size. That's exactly why scanners and fax machines love TIFF: a whole multi-page contract leaves as one file, with each sheet packed optimally inside.

1

Read the header

Take the first 8 bytes: determine the byte order, check for the number 42, and find the address of the first IFD.

2

Open the first IFD

Read the tag count, parse the tags: size, color, compression, the addresses of strips or tiles. That's page 1.

3

Assemble the pixels

Using the addresses from the tags, fetch the strips or tiles, decompress if needed — the page is ready to display.

4

Follow the link

At the end of the IFD, take the address of the next directory. Not zero — repeat steps 2–3 for the next page; zero — the file is done.

Why this matters

A multi-page TIFF is essentially a finished document. The most natural way to share it is to gather the pages into a single PDF: the order and independence of the sheets are preserved, and anyone can open it. You can do that in the TIFF to PDF converter.

LZW compression in plain English

Inside the strips and tiles, the pixels are usually compressed. The most famous method in TIFF is LZW (Lempel–Ziv–Welch), the same algorithm once used in GIF. The headline fact: it's lossless. The decompressed file matches the original byte for byte — not a single pixel suffers, unlike JPEG.

LZW works like a smart dictionary. Imagine you're copying out a text and notice the word "image" appears a hundred times. Instead of writing it out each time, you define a shorthand once — say, "#7" — and from then on write only that. LZW does the same with sequences of bytes: it finds repeating chains, adds them to a dictionary and replaces them with short codes. The more repetition in the data, the stronger the compression.

The elegant part is that the dictionary doesn't need to be stored in the file. Both the packer and the unpacker build it on the fly, by the same rules, reading the data in order. So when you open the file, the dictionary rebuilds itself, and the picture reassembles exactly as it was.

LZW doesn't throw data away — it finds the repeats in it and replaces them with shorthand. That's why the file is lighter and the quality doesn't change by a single pixel.

There's a subtlety worth knowing. On flat areas (logos, diagrams, text, black-and-white scans) repetition is plentiful — LZW shines. But on noisy photographs, neighboring pixels are almost always slightly different, repetition is scarce, and the gain is modest. Worse, on 16-bit images, naive LZW can sometimes even grow the file. The rescue is a predictor — a trick where, instead of the pixel values themselves, you store the difference from the neighbor. On smooth gradients the neighbors are close, the differences come out small and uniform, and now both LZW and ZIP compress noticeably tighter.

Other compression modes and when to use each

LZW isn't the only option. TIFF was designed as a "container," and the compression type is just the value of one of its tags. Here are the main modes and what each is good for.

MethodLossStrengthWhen to use
NoneNoMaximum compatibility, instant readsIntermediate files, ancient software
LZWNoFast, supported almost everywhereGraphics, text, the universal pick
ZIP (Deflate)NoCompresses tighter, especially with a predictorPhotographs, 16-bit files
PackBitsNoSimplest, very fastSimple graphics, app-to-app exchange
CCITT G3/G4NoTiny size for B/W documentsText scans, faxes (1-bit)
JPEG-in-TIFFYesSmallest weightRarely: when weight beats precision

A few rules of thumb, no formulas. CCITT G4 is the champion for compressing black-and-white text: a multi-page scanned contract weighs almost nothing in it, which is why scanners reach for it. ZIP with a predictor is the best default for photographs and deep color. LZW is for when you need maximum compatibility with older programs. And JPEG-in-TIFF exists, but it runs against the very idea of the format: if you're going to sacrifice quality anyway, it's simpler to save a separate JPG from your TIFF.

Layers, transparency and alpha

TIFF can store more than just color channels. People often muddle this up, so let's sort it out — these are two different mechanisms.

Transparency (the alpha channel). Beyond the color channels (RGB or CMYK), TIFF adds "extra samples" — the ExtraSamples tag. One of them is alpha: for each pixel it sets the degree of transparency. It comes in two flavors. Unassociated alpha stores color and transparency separately — the familiar mask. Associated (premultiplied) alpha has the color already multiplied by transparency; this makes compositing layers faster, but it has to be accounted for during conversion, or you'll get a dark or light fringe around the edges.

Photoshop layers. Full layers (as in a PSD) are stored more cunningly. The image itself is always kept flattened — that's what every program sees. The individual layers, Photoshop tucks into a private ImageSourceData tag. Open such a file in Photoshop and the layers are there; open it in any other viewer and you'll see only the final picture.

Don't trust layers in TIFF

Essentially only Photoshop understands layers in a TIFF, and the ImageSourceData tag bloats the file noticeably. If you need live layers, keep the working file as a PSD. A layered TIFF is best treated as a "just in case" backup, not a universal format for exchanging layers.

A layered topographic map with contour lines — an analogy for layers and geo-referencing in GeoTIFF
Layer by layer, coordinate by coordinate: GeoTIFF carries that very logic right into the file's tags. Photo: Pexels

BigTIFF and GeoTIFF: giants and special editions

Classic TIFF has a hard ceiling. All addresses inside the file are 32-bit, which means the file can't be larger than 4 gigabytes: beyond that, the addresses simply run out of bits to point at the byte you need. For a photo that's endless room, but for a satellite image of a whole country or ultra-high-resolution microscopy, it's tight.

BigTIFF lifts the limit. It's essentially the same TIFF, but with 64-bit addresses; and the magic number in the header changes from 42 to 43 — by which a program instantly knows it's looking at the "big" version. The theoretical ceiling rises to astronomical figures (millions of petabytes), so you can forget about 4 GB. From the outside it's all the same — the same tags, the same IFD logic — just wider addresses.

GeoTIFF solves a different problem — not size, but meaning. An ordinary picture doesn't know which place on Earth its pixels correspond to. GeoTIFF adds a few special tags with geographic referencing: the pixel scale on the ground (ModelPixelScale), reference points (ModelTiepoint) and a description of the coordinate system (GeoKeyDirectory). Thanks to the format's "tagged" nature these are just new tags — old programs ignore them and still show the picture, while GIS software reads them and pins the image precisely onto a map. GeoTIFF is the de facto standard for satellite imagery, elevation maps and aerial photography, and it's often paired with BigTIFF, because such data easily steps past 4 GB.

What this means in practice

Knowing the internals isn't theory for its own sake. Here's how it helps with everyday tasks.

  • You understand why TIFF is heavy. Lossless compression doesn't discard data, it only hunts for repeats. So a photo in TIFF is several times bigger than a JPG — and that's normal for a master file.
  • You choose compression deliberately. Text and scans — CCITT G4; photographs — ZIP with a predictor; need maximum compatibility — LZW. It directly affects file size.
  • You don't lose pages in conversion. Knowing that multi-page is a chain of IFDs, you won't be surprised that a good converter keeps every sheet. For a document, pick TIFF to PDF; for a single picture, TIFF to JPG.
  • You're careful with layers and alpha. Layers live only in Photoshop, and premultiplied alpha has to be handled correctly or you'll get a fringe around the edges.

Turn a multipage TIFF into a handy PDF

A chain of pages in a .tif is best turned into a single PDF — the sheet order is preserved, and anyone can open the file anywhere. Free, right in your browser, no install and no sign-up.

Convert TIFF to PDF

Don't need to assemble a document, just a lightweight copy of a single picture for the web or sharing? Then TIFF to JPG is the way. And the full list of conversions is always on the all formats page.

An IFD (Image File Directory) is the table of contents for one image inside a TIFF. It is a list of tags that describe width, height, color, compression type and the addresses of the pixels themselves. The file begins with an 8-byte header that points to the first IFD, and every IFD ends with a link to the next one. That chain is what makes TIFF multi-page.
Multi-page support in TIFF is a chain of IFDs. Each page is described by its own IFD with its own pixels, and the end of each IFD holds the address of the next one. A program reads the first page, follows the link to the second, and so on until the link is zero. That is how a single .tif file can store dozens of scanned sheets.
LZW is lossless. It is a dictionary algorithm: it finds repeating sequences of bytes, stores them in a dictionary and replaces them with short codes. On decompression the dictionary is rebuilt, and the image comes out byte-for-byte identical to the original. Not a single pixel is lost — unlike JPEG.
Both methods are lossless, but they work differently. LZW is older, faster and supported by almost all software. ZIP (Deflate) usually compresses tighter, especially photos and together with a predictor, but it is a little slower and less common in older programs. Photos are usually saved with ZIP, while LZW is the safe pick for maximum compatibility.
Transparency, yes: TIFF supports an alpha channel through an extra sample (ExtraSamples), either associated (premultiplied) or unassociated. Photoshop layers can also be saved, but they live in a private ImageSourceData tag and are only visible in Photoshop. Other programs show only the flattened image, so layers in TIFF are a safety net for Photoshop itself, not a universal layered format.