Start typing to search this publication.
oneblackpixel
Open menu

Subscribe to oneblackpixel

Get new posts delivered straight to your inbox.

A 1x1 black RGB PNG is 69 bytes in Pillow, 67 bytes with zlib Z_RLE

Why Pillow's default 1x1 #000000 PNG carries two extra IDAT bytes, a 15-line Python reproducer for the valid 67-byte RGB Color Type 2 floor, and how our audit caught the mistake.

oneblackpixel
3 min read

Every Python developer who has run Image.new("RGB", (1, 1), (0, 0, 0)).save("x.png") has generated the exact same 69-byte file (SHA-256: c47dd9465c00e9a0c8b85e9ea58d3034a0d23b9cf926113602f3460752a4eb96).

We initially claimed that 69 bytes was the RFC 2083 floor for an 8-bit RGB (Color Type 2) 1×1 PNG, and that 67 bytes required switching to Grayscale (Color Type 0). A byte-level code audit proved that assumption wrong: you can build a valid, Pillow-decodable 8-bit RGB Color Type 2 PNG in 67 bytes without changing the color type or violating RFC 2083.

Why Pillow emits 69 bytes instead of 67

A standalone 1×1 8-bit RGB PNG has a single 4-byte filtered scanline: [0x00, 0x00, 0x00, 0x00] (PNG Filter Type 0 followed by R=0, G=0, B=0). The container overhead is fixed at 57 bytes: 8-byte PNG signature + 25-byte IHDR + 12-byte IDAT length/type/CRC wrapper + 12-byte IEND.

Under Pillow's default zlib settings (Z_DEFAULT_STRATEGY), the IDAT zlib stream takes 12 bytes (78 9C 63 60 60 60 00 00 00 04 00 01), encoding literal zeros before the Adler-32 trailer (57 + 12 = 69 bytes).

Switch zlib to level 1 with Z_RLE and memLevel=1, and deflate emits a length-3 run-length match over the repeated zero bytes, compressing the exact same [0x00, 0x00, 0x00, 0x00] scanline into 10 bytes (78 01 63 00 02 00 00 04 00 01) — yielding 57 + 10 = 67 bytes total (SHA-256: e4f4d0ad4161e010dbe15c85de7b157650a49c9bab829f39528706d95382f5ac).

Reproducible Python test

import hashlib, io, struct, zlib
from PIL import Image

# 1) Standard Pillow RGB 1x1 black PNG -> 69 bytes
buf = io.BytesIO()
Image.new("RGB", (1, 1), (0, 0, 0)).save(buf, format="PNG")
b69 = buf.getvalue()
print("Pillow default:", len(b69), hashlib.sha256(b69).hexdigest())

# 2) Valid 8-bit RGB (Color Type 2) PNG in 67 bytes via zlib Z_RLE
def chunk(tag: bytes, data: bytes) -> bytes:
    return struct.pack(">I", len(data)) + tag + data + struct.pack(">I", zlib.crc32(tag + data) & 0xFFFFFFFF)

co = zlib.compressobj(level=1, method=zlib.DEFLATED, wbits=15, memLevel=1, strategy=zlib.Z_RLE)
zdata = co.compress(b"\x00\x00\x00\x00") + co.flush()
b67 = b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", 1, 1, 8, 2, 0, 0, 0)) + chunk(b"IDAT", zdata) + chunk(b"IEND", b"")

img = Image.open(io.BytesIO(b67))
img.load()
assert img.mode == "RGB" and img.size == (1, 1) and img.getpixel((0, 0)) == (0, 0, 0)
print("Z_RLE RGB:", len(b67), hashlib.sha256(b67).hexdigest())

Exact hex payloads side by side

  • 69B Pillow default: 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 00 00 00 01 00 00 00 01 08 02 00 00 00 90 77 53 DE 00 00 00 0C 49 44 41 54 78 9C 63 60 60 60 00 00 00 04 00 01 F6 17 38 55 00 00 00 00 49 45 4E 44 AE 42 60 82

  • 67B zlib Z_RLE RGB (Color Type 2): 89 50 4E 47 0D 0A 1A 0A 00 00 00 0D 49 48 44 52 00 00 00 01 00 00 00 01 08 02 00 00 00 90 77 53 DE 00 00 00 0A 49 44 41 54 78 01 63 00 02 00 00 04 00 01 B1 86 90 44 00 00 00 00 49 45 4E 44 AE 42 60 82

Genuine question for PNG/deflate engineers: given the 57-byte mandatory container overhead for an 8-bit RGB Color Type 2 PNG and the 6-byte zlib header + Adler-32 trailer (leaving 4 bytes for the deflate bitstream), can any strictly RFC 2083 / RFC 1950 compliant 1×1 RGB PNG compress below 67 bytes?

Context: why we were auditing two bytes of black

That exact 69-byte Pillow default is the image payload behind our open conceptual web experiment BLACK PIXEL (1×1) (interactive byte dissector at dossier.html#binary-dissector) — Ethereum ERC-1155 Token #1, listed at 413 ETH (which we realized post-factum mirrors HTTP 413 Content Too Large, RFC 9110 §15.5.14).

Once the code audit caught the 2-byte Z_RLE discrepancy, we left the original 69-byte Pillow default on-chain, logged both findings (#001 and #002 SUSTAINED) in our public Register of Objections, put a direct $0 download of all 69 bytes on the homepage, audited our CDN logs (30,500+ raw hits vs. ~390 real browser sessions), and published a $0-gas off-chain custodian signature (Etherscan #342558). Full project log and errata live at history.html.

Subscribe to oneblackpixel