wire / wire-format / png-structure
A PNG file starts with an 8-byte signature, then a sequence of chunks. Each chunk: 4-byte length (big-endian), 4-byte type (ASCII), length bytes of data, 4-byte CRC-32 (over type+data). Critical chunks: IHDR (image header), PLTE (palette), IDAT (image data), IEND (end). Ancillary chunks: tEXt/zTXt/iTXt (metadata), gAMA, cHRM, sRGB, pHYs, tIME, bKGD, etc.
aka: PNG file structure
spec: W3C PNG specification (ISO/IEC 15948)
A PNG file starts with an 8-byte signature, then a sequence of chunks. Each chunk: 4-byte length (big-endian), 4-byte type (ASCII), length bytes of data, 4-byte CRC-32 (over type+data). Critical chunks: IHDR (image header), PLTE (palette), IDAT (image data), IEND (end). Ancillary chunks: tEXt/zTXt/iTXt (metadata), gAMA, cHRM, sRGB, pHYs, tIME, bKGD, etc.
| field | size | meaning |
|---|---|---|
| PNG signature | 8 bytes | 0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A. |
| Chunk length | 4 bytes | Length of the chunk data field (big-endian). Max 2^31-1. |
| Chunk type | 4 bytes | ASCII type code (e.g. 'IHDR', 'IDAT', 'IEND', 'PLTE', 'tEXt'). |
| Chunk data | = length | The chunk's payload (structure depends on type). |
| Chunk CRC | 4 bytes | CRC-32 (IEEE) over chunk type + chunk data. |
| IHDR data | 13 bytes | Width (4), Height (4), Bit depth (1), Color type (1), Compression (1, always 0), Filter (1, always 0), Interlace (1, 0/1). |
example:
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
PNG signature + IHDR for a 1x1 8-bit RGB image
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/png-structure
or /wire-format/png-structure.json