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 group | Files | What a failure looks like |
|---|---|---|
| Bilevel compression | 6 TIFF | One of the six schemes decodes wrongly, or not at all |
| 8-bit RGB | 2 TIFF | Channels swapped, or a JPEG source read as raw samples |
| CMYK | 1 TIFF | Inverted colour, or the four inks not separated |
| Grey and palette | 2 TIFF | Palette indexes read as grey, or the reverse |
| RGBA | 1 TIFF | Alpha dropped, or colour multiplied by alpha twice |
| 16-bit grey | 1 TIFF | The low byte kept instead of the high one |
| Multi-page | 1 TIFF, 3 pages | Only the first page returned, or pages out of order |
| PNG layouts | 12 PNG | Adam7, tRNS or 16-bit pixels handled wrongly |
| Negative files | 4 | A file accepted that should have been refused |
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 compression | Pixels wrong |
|---|---|
| LZW | 2,168 of 9,600 |
| CCITT G4 | 1,529 of 9,600 |
| CCITT G3 | 1,096 of 9,600 |
| Deflate | 5 at that bit; a sweep of all 912 bit positions in the same strip reached 6,588 |
| PackBits | 1 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.