Portable Network Graphics

from Wikipedia, the free encyclopedia
Portable Network Graphics
File extension : .png
MIME type : image / png
Magic number : 8950.4e47.0d0a.1a0a hex
\ x89PNG \ r \ n \ x1a \ n

( ASCII-C notation )

Developed by: PNG Development Group (thanks to W3C )
Type: Lossless bitmap - graphics format
Expanded to: APNG , JNG , MNG
Standard (s) : ISO 15948 , IETF RFC 2083
Website : libpng.org/pub/png

Portable Network Graphics ( PNG , English for portable network graphics, also pronounced syllable as an acronym [ pɪŋ ]) is a raster graphics format with lossless data compression . It is recognized by the World Wide Web Consortium (W3C) and is the most widely used lossless graphics format on the Internet.

PNG was as a free replacement for the older, by the year 2006 with patent claims loaded Graphics Interchange Format designed (GIF), and is less complex than the Tagged Image File Format (TIFF). In addition to different color depths , PNG also supports transparency via alpha channel . PNG photos are typically much larger than JPEG . For a long time, the PNG format could not be easily displayed in browsers, so that it took years to assert itself alongside JPEG and GIF.


The development of the PNG format began at the end of 1994, which is quite late compared to other graphic formats such as TIFF, GIF and JFIF (JPEG). The trigger was license requests from the software company Unisys for the Lempel-Ziv-Welch algorithm (LZW) used by GIF .

On January 4, 1995, Thomas Boutell submitted an early draft (PBF Draft 1). The first correct PNG specification (version 1.0) by Thomas Boutell and Tom Lane became the official recommendation of the World Wide Web Consortium (W3C) on October 1, 1996 . On October 14, 1996, PNG was assigned the MIME type by the Internet Assigned Numbers Authority (IANA) . On January 15, 1997, PNG was passed as RFC 2083 by the Internet Engineering Task Force (IETF) . On December 31, 1998, the revised PNG specification version 1.1 by Adam Costello and Glenn Randers-Pehrson appeared. On August 11, 1999, Glenn Randers-Pehrson finally published the last version 1.2. This was elevated to ISO standard ISO / IEC 15948: 2003 on November 10, 2003 and at the same time became the second edition of the W3C recommendation. image/png

The PNG format is now widely used; Above all, it has replaced GIF in graphics that are highly compressible without loss, such as buttons, icons and logos. It is mostly only used for photos if their lossless storage takes precedence over a small data size, since lossy compression (e.g. by JPEG) photos i. A. can compress even more, without significant loss of quality for the human eye.


Color modes and precision

The PNG format enables grayscale , full-color and color palette modes , as well as a grayscale and a color mode with alpha channel (color types 0, 2, 3, 4 and 6).

Color depths

For grayscale images, the resolution can be 1, 2, 4, 8 or 16 bits per pixel, for color images 8 ( RGB 8) or 16 bits (RGB16) per color channel . Alternatively, color images can be saved with up to 256 indexed colors using the color palette mode. The indexed colors can be freely selected from the full RGB8 spectrum.


PNG files can contain transparency information, either in the form of an alpha channel, as a single transparent color, or as a transparency palette that supplements an existing color palette that contains a transparency value for each palette color.

PNG supports alpha channels with 8 bit or 16 bit depth. It is a channel with additional information for each pixel. This indicates the opacity in different levels of how much of the background of an image should shine through. If this value is 0, the background shows through 100% completely. If the maximum value of 255 is specified for a depth of 8 bits (or 65535 for 16 bits), this corresponds to complete coverage. The background is not visible in this case.

The PNG format therefore allows the edges of text and images to be smoothed regardless of the background . You can use real drop shadows that hide in the background.

Metadata and data blocks

PNG files are made up of different data blocks ("chunks"), each with different functions, which are identified by a string of four letters ( e.g. tEXt for textual information). In addition to the mandatory block types IHDR, IDAT, PLTE and IEND, which every implementation must support, other optional data blocks are standardized. These can contain metadata about the image content and other additional information, such as color correction . These can be edited with programs like TweakPNG . Applications can also define private data blocks for their own purposes. Adobe Fireworks uses PNG as its application format and uses private blocks of data to store various other information in it. However, there is also a risk of confusion with the much smaller, normal PNG files.

Technical details

File header

A PNG file always begins with the following eight-byte signature ( magic number ):

Byte (s) (hex) comment
89 Tabulator with bit 7 set
50 4E 47 ASCII character string "PNG"; allows the file format to be easily identified in text view or in a text editor.
0D 0A CR and LF ( MS-DOS- typical line ending)
1A The End of File sign .
This byte would abort the output if the file were output with the MS-DOS command TYPE , for example .
0A Line feed


Example file with various types of content
Representation of the bit costs per pixel of the above PNG image
(dark / blue: low bit costs, green: medium costs, red: high bit costs)

The lossless data compression in PNG is based on several, sometimes optional, processing steps. First, the values ​​of neighboring pixels can be decorrelated with a pre-filter in order to be able to describe them in a more compressible manner via a difference to neighboring values. Then an attempt can be made with a substitution compression method to recognize recurring image patterns and to replace them with shorter back references to a previous occurrence. Finally, an entropy coding is used that uses the probabilities of occurrence of individual values ​​by replacing the values ​​sorted by probability with codes of variable length.

The adjacent “banana image” shows which image areas can be compressed and how efficiently.


A PNG image with 256 colors that, thanks to the pre-filter, is only 251 bytes in size. The same image as a GIF file would be more than 13 times the size.

As a rule, the color value of an image point correlates with the values ​​of neighboring points, that is, there is a dependency or similarity. In order to take advantage of these correlations, PNG supports pre-filters which first decorrelate the output data. As a result, image points are described using the difference to neighboring points ( delta coding ). One of 5 filter options can be defined for each image line (see below). For reasons of speed, the selection is often made heuristically. These filters replace the color values ​​of the pixels in a reversible manner by (just as many, just as large) difference values. As a rule, this difference signal has a significantly lower dynamic, i.e. values ​​with on average smaller amounts. These can be compressed more effectively by the final entropy coding. The more uniform the image content, the more profitable this mechanism works. During decoding, after the data has been decompressed, reverse versions of the filters are used to restore the actual image data.

This possibility is one of the reasons for the small size of PNG files.

In the current version, PNG defines five different filter types:

number Surname description
0 None No pre-filtering. The original pixel data is used.
1 Sub The differences to the pixel adjacent to the left are processed.
2 Up The differences to the pixel above are processed.
3 Average The difference to the mean value is calculated from the pixel above and the pixel adjacent to the left.
4th Paeth A so-called Paeth Predictor value is calculated from the pixel adjacent to the left, the one above it and the one diagonally above left , which determines the pixel for the difference formation.

Some coders try several filters to improve compression. This is a common technique, especially with the numerous tools for optimizing PNG compression.

In many cases, the Paeth Predictor, named after its inventor, Alan W. Paeth , offers the best results. With this, an attempt is made to automatically use the most similar image points from the neighboring image points on the left, top and top left for the difference formation. The function selects the pixel that comes closest to the left + top − top left.

Substitution compression and entropy coding

are carried out according to the popular deflate method, as this can be used freely without being burdened by software patents . It includes substitution compression according to Storer, Szymanski, Lempel and Ziv ( LZSS algorithm ) and entropy coding according to Huffman .

Many programs incorporate the free deflate library zlib for deflate coding and decoding ( codec ) , which was originally created especially for PNG. Deflate compression can usually (as in other applications - for example with ZIP compression) be set in the output program in 10 levels from 0 (none) to 9 (best).

So far, Deflate is the only supported method. However, there has been deliberately left room for extensions in order to support other, more efficient or faster algorithms in future PNG versions. In order to ensure downward compatibility with existing PNG-compatible programs, there are currently no plans to include other methods in the standard.


Color profiles

Except for Safari and Firefox (after activation), no browser supports embedded color profiles (iCCP blocks). Therefore, they do not offer full color management. Because Safari is the only browser to display complete color profiles, a uniform and cross-platform display of images in PNG format with an embedded color profile is currently not possible. This function is planned for the future, at least for the Firefox browser. Embedded gamma correction values ​​(gAMA blocks), on the other hand, are correctly recognized and processed by most current browsers.


Microsoft Internet Explorer up to version 6 had problems with the display of transparent PNG files with an alpha channel; However, PNG files with binary (“yes / no”) transparency were displayed without errors.


The PNG format is not subject to any patent restriction . Any software manufacturer can therefore publish programs that can read and write PNG without paying license fees.



  • The compression is lossless and mostly more compact than comparable formats.
  • Support of alpha transparency (up to 16 bits, i.e. 65,536 levels; 8 bits are common).
  • Support of color and brightness correction mechanisms to ensure that an image looks approximately the same on different systems.
  • The format is subject to a fixed standard and is expandable, so that theoretically every program must meet certain minimum requirements. In addition, PNG is both upwards and downwards compatible, which reduces incompatibilities between different versions.
  • Integrated checksums make it possible to detect errors in the file at an early stage.
  • PNG files are streamable , which means that the interpretation of the file content does not require random access, as is the case with many TIFF files.
  • An optional interlacing with 7 passes according to Adam M. Costello (" Adam7 ") is available, ie the gradual image build-up during transmission over slow data lines. Even with very little transmission, a relatively useful display is possible.
  • Support from all graphic web browsers is available (in Internet Explorer , however, alpha transparency is only supported from version 7.0).


  • It does not offer any animation. The MNG format was created for this purpose, but it is hardly supported, as is the APNG format. However, there are various web techniques to animate PNG using spritesheets (as supported by Facebook , for example , as opposed to animated GIF).
  • Does not support the CMYK color model and is therefore not suitable as a complete TIFF replacement.
  • Although it supports embedded meta information, it does not comply with either the Exif or the IPTC standard .
  • Does not allow easy loading of parts of the image. If you only want to load a section of the image, you have to load all image lines beforehand. In the case of PNG files that were saved interlaced rather than sequentially, even more must be loaded.
  • With certain types of images (e.g. photos), the format naturally does not achieve the compression rates of lossy algorithms such as JPEG . Even in comparison with algorithms specializing in certain classes of image data, for example only for scanned documents ( e.g. JBIG2 ), PNG can usually not keep up.

Comparison with Graphics Interchange Format (GIF)

In the absence of animation options, PNG is an incomplete alternative to the GIF format. Animation options are outsourced to a separate format with PNG. The two formats together should completely replace GIF; this has not happened to this day.

In addition to the color palette mode, PNG also supports full color and grayscale images with a precision of up to 16 bits per color channel. With GIF it is only possible to declare one of the pallet entries as completely transparent.

The compression rate of PNG is usually better than that of GIF. The pre-filters are the reason why PNG files usually take up less space. On the other hand, the complexity of the format is also higher.

With PNG's progressive image structure with Adam7 interlacing, significantly less image distortion occurs than with GIF.

Until 2004, the use of the GIF was limited by the use of the patented LZW algorithm, of which PNG was free from the start. (GIF was still limited by other patents until October 2006.)

Related formats

Neither MNG, JNG, nor APNG or PNG + are W3C recommendations.


The official reference implementation for the PNG format is the libpng program library . It is subject to a free software license and is therefore usually also found as an important system library in free operating systems. PNGOUT and Zopfli PNG are well-known PNG encoders optimized for the most compact compression. There are a number of auxiliary programs for file size optimization for PNG files, which are mainly known for their use in optimizing website loading times and which are often based on these two special encoders, among others. Many programs do not save PNG images optimally, which leads to unnecessarily large files. Various programs such as pngcrush , OptiPNG or others enable lossless recompression and often much smaller files.

All modern web browsers now support the format. Important image processing programs usually support it in both reading and writing.


Web links

Commons : Portable Network Graphics  - collection of pictures, videos, and audio files

Individual evidence

  1. Image Media Types. Internet Assigned Numbers Authority , September 27, 2009, accessed October 6, 2010 .
  2. PNG (Portable Network Graphics) Specification, Version 1.2. 12.12. PNG file signature. July 14, 1999, accessed October 6, 2010 .
  3. Usage of image file formats for websites , English
  4. Sibylle Mühlke: Adobe Photoshop CC, 7th edition 2018, p. 1051
  5. Linux Foundation Wiki: LibPng - Specification Overview ( Memento of the original from September 5, 2014 in the Internet Archive ) Info: The archive link was inserted automatically and has not yet been checked. Please check the original and archive link according to the instructions and then remove this notice. @1@ 2Template: Webachiv / IABot / wiki.linuxfoundation.org
  6. Jason Summers: TweakPNG , English
  7. Comparison of the properties (including compression) of BMP, GIF, PNG, JPEG, TIFF, PCX and TGA , accessed October 10, 2012
  8. Stephen T. Lavavej: Introduction to PNG. In: nuwen.net. Retrieved October 6, 2010 .
  9. libpng. Retrieved July 13, 2013 .
  10. Cosmin Truţa: A guide to PNG optimization . (with directory of programs for lossless recompression, English)