File compatibility

TIFF Test Images: A Small Suite With Ground Truth

By Pavel Demidovich · 28 October 2026 · 9 min read

Two test sheets, labelled truth-rgb.bin and decoded pixels, with one red cell marking a wrong pixel in the second.

Audio article · first 1,000 words

Listen to this article 7 min · 5 chapters
Chapter 1 of 5 Introduction
0:00 / 6:54
Contents

Press a timecode by a heading, or any sentence in the text, to listen from there.

TIFF test images are files whose decoded pixels are known in advance. A sample proves a decoder opened the file; a test image proves it read the file correctly. We keep 33 of them for our own TIFF and PNG decoder, and this page describes what they catch and what they leave out.

The TIFF test suite is 455,946 bytes across 33 files. Every image is 120 by 80 pixels, 9,600 in all, small enough to check by hand and wide enough to exercise a full compressed strip. Three files ship beside the images as raw ground truth: the expected bytes, one sample per byte, in row order.

Ground truth here means the decoded samples themselves, not a screenshot and not a hash. For the RGB image that is 28,800 bytes, three per pixel. A decoder passes when its output equals those bytes and fails when one byte differs.

Most collections of TIFF test images answer where to download a file. This one answers what the file should prove, and publishes its generator so the suite can be rebuilt and checked.

Quick answer

A TIFF test image is a small file with a known decoded result. Cover one file per feature, store the expected pixels as raw bytes, and compare the decoder’s output with them. A sample photo shows that the file opened; ground truth shows whether it was read correctly.

We build the decoder this suite tests, so the file list and the damage numbers come from our own tests. The formats follow the TIFF 6.0 and W3C PNG specifications, and the generator ships with the archive.

Why a sample photo cannot test a decoder

A photo that opens on screen proves that a decoder returned an image, not that it returned the right one. Visual checks catch a gross shift or a swapped channel; they miss one wrong pixel, a row offset by one, or a palette entry off by one.

Size makes this worse, not better. A 10 MB scan shows nothing on inspection unless the original is beside it. Sample TIFF files for testing are sized for a form’s limit, not for a reader’s edge cases.

A TIFF reader has three questions: does it refuse what it cannot decode, does it accept every feature it claims, and does it return the exact samples stored in the file. A photograph answers none of them.

What the suite covers

Every file is 120 by 80, so two decoded results can be compared without scaling or resampling. TIFF 6.0 defines the compression schemes the suite uses: baseline uncompressed and PackBits, plus the LZW and CCITT extension encodings. The suite writes one bilevel file per scheme (TIFF 6.0 specification), and one more for Adobe Deflate, which the specification does not include.

Feature groupFilesWhat a failure looks like
Bilevel compression6 TIFFOne of the six schemes decodes wrongly, or not at all
8-bit RGB2 TIFFChannels swapped, or a JPEG source read as raw samples
CMYK1 TIFFInverted colour, or the four inks not separated
Grey and palette2 TIFFPalette indexes read as grey, or the reverse
RGBA1 TIFFAlpha dropped, or colour multiplied by alpha twice
16-bit grey1 TIFFThe low byte kept instead of the high one
Multi-page1 TIFF, 3 pagesOnly the first page returned, or pages out of order
PNG layouts12 PNGAdam7, tRNS or 16-bit pixels handled wrongly
Negative files4A file accepted that should have been refused
Ten labelled test images in a grid, from bilevel LZW to a multi-page TIFF.
Ten files from the suite, decoded with Pillow and shown at their true pixels: bilevel LZW, RGB, JPEG-in-TIFF, CMYK, grey, palette, a 16-bit PNG, RGBA, an interlaced PNG and the second page of a multi-page TIFF. The checkerboard shows through only the RGBA tile, where the file stores transparency.

Bilevel compression

Six files carry the same bitmap through no compression, LZW, PackBits, Adobe Deflate, CCITT Group 3 and CCITT Group 4. All six decode to the same 9,600 bits, so a decoder that gets one scheme wrong stands out immediately.

The file sizes show why the same pixels need six files: 1,310 bytes uncompressed, 370 with LZW, 980 with PackBits, 236 with Deflate, 2,450 with Group 3 and 1,526 with Group 4. The comparison is between decoded bits, not byte counts.

Some browser libraries handle LZW and PackBits but not the fax schemes. The suite shows that gap in one test run rather than in a customer’s scanned document.

Colour layouts

The seven remaining colour files cover RGB, RGB compressed with JPEG, CMYK, greyscale, palette, RGBA and 16-bit greyscale. Each failure has a signature: a CMYK file read as RGB is inverted, a palette file read as grey is a plausible but wrong ramp, and a 16-bit file read as 8-bit loses precision quietly.

Two of those files need a caveat. The JPEG-compressed TIFF is lossy, so its decoded pixels will not equal truth-rgb.bin; test it for tolerance or simply for decoding without error. And pattern-rgba.tif carries alpha at 255 throughout; the varying alpha lives in the PNG file instead. What each format can carry is the wider version of that distinction.

PNG files for the reverse direction

Twelve PNG files cover the other direction, because the same converter reads and writes PNG. The patterns are shared, so truth-rgb.bin serves pattern-rgb.tif and pattern-rgb.png, and a round trip can be checked from either side.

PNG adds layouts TIFF does not have: Adam7 interlacing, tRNS colour keys, and per-entry palette alpha. The rules are in the W3C PNG specification, and the suite uses them.

The pattern is the test

The bitmap is not a checkerboard. A checkerboard hides fax-decoder bugs because every row is identical, so a row offset shows nothing. The pattern has a horizontal bar at rows 10 to 19, a diagonal where x is twice y, and a band below row 40 where three times x plus y modulo five is below two. Most rows differ from their neighbours: only rows 10 to 19 repeat, because the bar covers the diagonal there. A row offset still shows in the rows the bar does not cover, and the three shapes fail differently.

Colour uses another rule again: red is twice x, green is three times y, blue is five times x plus y, each modulo 256. The three formulas differ, so a swapped pair changes the picture. Alpha follows a third formula, seven times x plus thirteen times y, so applying alpha to the wrong channel shows.

The 16-bit trap

A 16-bit test image is easy to write in a way that proves nothing. If the high byte equals the low byte, a decoder that keeps either one produces the same result. pattern-gray16.png is built that way on purpose: each value is an eight-bit level multiplied by 257, so the two bytes agree.

pattern-gray16-mixed.png removes the ambiguity. Its high byte is x and its low byte is y, wrapped to a byte, so a decoder that keeps the wrong byte returns a different picture. At 16,301 bytes it is far larger than pattern-gray16.png, because the pattern compresses badly.

On the TIFF side, pattern-rgb16.tif is 16-bit greyscale and 19,322 bytes. Our converter keeps the top eight bits, the same reduction a screen makes; what a 16-bit TIFF loses in an 8-bit PNG covers that trade.

Palette alpha and tRNS

pattern-palette-alpha.png is a 4-bit palette image with 16 entries. Its tRNS chunk carries alpha for the first eight indexes only, and the specification says the rest stay opaque. A decoder that requires an entry for every index, or ignores the chunk, fails on half of the palette.

Two more files test colour keys: pattern-rgb-trns.png makes the colour at pixel zero transparent wherever it occurs, and pattern-gray4-trns.png makes level 5 of 15 transparent. Ignoring tRNS returns an opaque image that otherwise looks correct, which is exactly the failure a visual check misses.

Ground truth turns “looks right” into a pass

The comparison is a few lines of Python when the decoder is Pillow. Decode the file to the same layout as the truth, then compare sample by sample:

from pathlib import Path
from PIL import Image

expected = Path("fixtures/truth-rgb.bin").read_bytes()
decoded = Image.open("fixtures/pattern-rgb.tif").convert("RGB").tobytes()

wrong = sum(
    1
    for i in range(0, len(expected), 3)
    if decoded[i : i + 3] != expected[i : i + 3]
)
print(f"{wrong} of {len(expected) // 3} pixels differ")

Three details matter. Pillow opens the bilevel file in mode 1 and tobytes() packs eight pixels into a byte, 1,200 bytes, while truth-bilevel.bin is unpacked: 9,600 bytes, one per pixel, 1 for black; compare getpixel() or unpack the bits. truth-rgba.bin belongs to pattern-rgba.png, not to pattern-rgba.tif. And a 16-bit file needs its top byte extracted first, or convert() reduces it.

The four files that should fail

A decoder is also judged on what it refuses. The suite carries four files that no correct decoder should accept. notatiff.tif is 28,800 bytes of raw RGB samples under a .tif name. garbage.tif begins with a valid TIFF header and continues with deterministic SHA-256 noise that forms no readable page directory. notapng.png is a TIFF’s bytes under a .png name, and cut.png is a valid PNG cut to three quarters of its length.

The test is not only that each file is rejected, but that the reason is stated and no partial picture is produced. Our decoder stops on structural damage rather than filling the gap, as a TIFF that will not open describes from the reader’s side.

What one flipped bit costs

Damage inside a compressed strip does not always stop a decoder. LZW and the fax schemes share state across the strip, so one wrong bit can change everything after it. We measured the cost by flipping one bit in the middle of each compressed bilevel file and counting the pixels that differed from truth-bilevel.bin:

Source compressionPixels wrong
LZW2,168 of 9,600
CCITT G41,529 of 9,600
CCITT G31,096 of 9,600
Deflate5 at that bit; a sweep of all 912 bit positions in the same strip reached 6,588
PackBits1 of 9,600

Those numbers describe one image and, except for the Deflate sweep, one bit position per scheme. They are not an estimate for every damaged TIFF. They do show that PackBits can hide damage in one pixel while LZW turns it into nearly a quarter of the page.

A decoder that returns an image without an error is not therefore correct. That is the argument for expected pixels: the page finished, and it was wrong.

What the suite does not cover

The suite is a decoder’s unit test, not a conformance test. It does not include tiled TIFFs, PlanarConfiguration 2, 12-bit or 14-bit samples, floating-point or 32-bit samples, BigTIFF, YCbCr, Lab, ICC profiles, the orientation tag, LZW predictor, the old JPEG variant called OJPEG, more than three pages, or the noise of a real scanner.

Some of those are deliberate refusals. Our converter refuses 32-bit and floating-point TIFFs rather than reducing them, so no fixture would pass. Others are simply the next round of files to write. Naming the gaps matters: a suite that implies complete coverage is worse than one that lists its omissions.

How to run the suite

The TIFF test files are one download: tiff-test-files.zip, 336,865 bytes. Inside are fixtures/ with the 33 files, make-fixtures.py and a README that records the truth sizes and names the four negative files.

Unzip it into your decoder’s test directory and compare against truth-rgb.bin, truth-bilevel.bin or truth-rgba.bin. The generator runs with python3 make-fixtures.py and needs Pillow built with libtiff. It writes the same bytes every time, so a regenerated suite diffs clean.

Two sources for more files: LibTIFF publishes its own test images, and tlnagy/exampletiffs collects TIFF variants. Neither ships expected pixels, which is the gap this suite fills.

If you want to see a decoder’s results rather than build a harness, our decoder handles the same files in Chrome and converts locally, with no upload.

Final verdict - TIFF test images

A TIFF test image is only a test when its decoded pixels are known. Download the suite, compare small files against raw ground truth, and check the four negative files for a stated refusal. A pass means the decoder read these files correctly; the omissions list says what it still has not proved.

Frequently asked questions about TIFF test images

What are TIFF test images?

TIFF test images are small files whose decoded pixels are known in advance. They are used to check that a decoder returns the exact samples stored in the file, not just a picture that looks right. A suite pairs each file with expected output so the test can pass or fail without a person looking at the screen.

What should a TIFF test file contain?

One feature that can fail on its own: a compression scheme, a colour layout, a bit depth, or a second page. The image should be small enough to compare by hand, and the pattern should differ from row to row so a row offset cannot hide. Storing the expected pixels beside the file turns a sample into a test.

How do I test a TIFF decoder?

Decode each file to the same layout as the expected output, then compare the samples one by one. Include files for every compression scheme and colour layout you claim, plus a few files that must be refused. A decoder that returns an image without an error can still be wrong, so the comparison is in bytes rather than visible quality.

What is ground truth in image testing?

Ground truth is the expected decoded result, stored as raw samples rather than as a picture. In this suite truth-rgb.bin holds 28,800 bytes, three per pixel in row order, and truth-bilevel.bin holds 9,600 bytes, one per pixel with 1 for black. A decoder passes when its output matches those bytes exactly.

Can I use a normal photo as a TIFF test file?

A photo is useful for checking that a file opens, but it cannot prove that the pixels are right, because you have nothing exact to compare against. It is also large and full of detail that hides small errors. Use a photo for a smoke test and a small patterned file with expected output for the real check.

Do TIFF test files need to be large?

No. Every image in this suite is 120 by 80 pixels, and each file is under 87 KB. Small files decode fast enough to run in a unit test, are easy to inspect by hand, and still exercise a full compressed strip. Large files are worth adding for timing and memory checks, not for correctness.

How do I test a damaged TIFF file?

Keep a few files that no correct decoder should accept: raw bytes under a .tif name, a valid header followed by noise, and a file cut short. The test is that each is refused with a reason and no partial picture. Damage inside a compressed strip is different: the file decodes, and the pixels are wrong without an error.

Does this suite cover every TIFF feature?

No. The suite leaves out tiled TIFFs, planar configuration 2, 12-bit and 14-bit samples, floating-point data, BigTIFF, YCbCr and Lab colour, ICC profiles, EXIF orientation and the old JPEG variant. It is a decoder's unit test, not a conformance test, and the article names each gap rather than implying complete coverage.