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.
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 IHDR chunk comes first and gives the width, height, bit depth, colour
type and interlace method. 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, gamma, colour profiles, text and timestamps.
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
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