Introduction
PNG is a raster image format with lossless compression. It was designed in 1995 and 1996 as a free replacement for GIF, whose LZW compression was then covered by a patent. It became a W3C Recommendation in 1996 and an international standard, ISO/IEC 15948, in 2004.
A PNG can hold greyscale, truecolour or palette images at up to 16 bits per channel,
with full alpha transparency. It is the usual format for screenshots, diagrams and web
graphics with sharp edges. Animated PNG (APNG,
sometimes saved as .apng) adds frames through extra chunks that older readers
skip. It is part of the Third Edition of the specification, published in 2025.
Structure
A PNG file is an 8-byte signature followed by a series of chunks. Each chunk is a
4-byte big-endian length, a 4-byte type such as IHDR, the data, and a CRC-32
of the type and data. The case of each letter in the type carries a flag: an upper case
first letter marks a chunk that a reader must understand. The
Signature and chunks page covers these and the rules
for which chunks may appear and in what order.
The IHDR chunk comes first and gives the width, height, bit depth, colour
type and interlace method (see Image header and palette).
A palette image has a PLTE chunk. The pixels are
filtered row by row, compressed as one zlib stream
and split across one or more IDAT chunks. IEND closes the file.
Optional chunks carry transparency and colour information,
text, and
physical size, timestamps, Exif and suggested palettes, and
there are registered extensions for scientific
images and converted GIFs.
0Signature89 50 4E 47 0D 0A 1A 0A8 bytes8IHDR width, height, bit depth, colour type, interlace25 bytes33PLTE, tRNS, gAMA, tEXt … optional chunksvaries…IDAT the compressed pixels, in one or more chunksvaries…IEND the end of the image12 bytes
Not described
Known, not yet covered
- Viewer:
sBIT(significant bits) is shown but not applied to the picture. - Viewer: a
dSIGsignature is shown but not verified. - Viewer: 16-bit images are drawn from the high byte of each sample.
Unknown
- Reference and viewer: the layout of the
fRAc(fractal) chunk, which was registered but never published. Shown as labelled bytes.
Links
Software
- GIMP – free image editor that opens and saves PNG (Windows, macOS, Linux)
- Adobe Photoshop – Adobe’s image editor, which opens and saves PNG (Windows, macOS)
- Krita – free painting program that opens and saves PNG (Windows, macOS, Linux)
- Paint.NET – free image editor that opens and saves PNG (Windows)
- IrfanView – image viewer and converter (Windows)
- XnView MP – image viewer and batch converter (Windows, macOS, Linux)
- ImageMagick – command-line tools that convert and edit PNG (Windows, macOS, Linux)
- Squoosh – Google’s image compressor that runs in the browser (web)
- OptiPNG – command-line tool that makes PNG files smaller without loss (Windows, macOS, Linux)
Developers
Reference
- Portable Network Graphics (PNG) Specification – the W3C specification
- Registered PNG Extension Chunks – the register of oFFs, pCAL, sCAL, sTER and the GIF chunks