- This article contains text copied from Wikipedia under the terms of the GFDL. It needs to be edited to have a Computer vision focus.
PNG (Portable Network Graphics) is a lossless bitmap image format. PNG was created to both improve upon and replace the GIF format with a image file format that does not require a patent license to use.
The PNG standard specifies that PNG should be pronounced "ping" (Template:IPA in International Phonetic Alphabet for English).
History and developmentEdit
The motivation for creating the PNG format came in early 1995, after Unisys Corporation announced that it would be enforcing software patents on the LZW data compression algorithm used in the GIF format. The algorithm is described in U.S. Patent 4,558,302 and other patents around the world. There were also other problems with the GIF format which made a replacement desirable, notably its limitation to 256 colors at a time when computers capable of displaying far more than 256 colours were becoming common. Although GIF allows for animation, it was decided that PNG should be a single-image format. A companion format called MNG has been defined for animation. PNG gained some additional popularity in August 1999, after Unisys terminated its royalty-free patent licenses to developers of free software and non-commercial software.
- Version 1.0 of the PNG specification was released on July 1 1996, and later appeared as RFC 2083. It became a W3C Recommendation on October 1 1996.
- Version 1.1, with some small changes and the addition of three new chunks, was released on December 31 1998.
- Version 1.2, adding one extra chunk, was released on August 11 1999.
- PNG is now an International Standard (ISO/IEC 15948:2003), also released as a W3C Recommendation on November 10 2003. This version of PNG differs only slightly from version 1.2 and adds no new chunks.
The MIME media type for PNG is
image/png (approved on October 14 1996).
A PNG file consists of an 8-byte signature (89 50 4E 47 0D 0A 1A 0A in hexadecimal, which contains the letters "PNG" and 2 newlines, among other things ) followed by a number of chunks, each of which conveys certain information about the image. Chunks declare themselves as critical or ancillary, and a program encountering an ancillary chunk that it does not understand can safely ignore it. This chunk-based structure is designed to allow the PNG format to be extended while maintaining compatibility with older versions.
'Chunks' within the fileEdit
- IHDR must be the first chunk, it contains the header
- PLTE contains the palette (list of colours)
- IDAT contains the image
- IEND marks the end of the image
Other image attributes that can be stored in PNG files include gamma values, background color, and textual metadata information. PNG also supports color correction with the use of color management systems like sRGB.
- bKGD gives the default background colour
- cHRM give the white balance
- gAMA specified gamma
- hIST can store the histogram, or total amount of each colour in the image
- iCCP is an ICC color profile
- pHYs is the physical size of the image
- sBIT (significant bits) indicates the colour-accuracy of the source data
- sPLT suggests a palete to use if the full range of colours is not available
- sRGB indicates that standard RGB colours are used
- tEXt can store any text, with one name=value pair for each chunk
- tIME stores the time that the image was last modified
- tRNS contains transparency information. For indexed images it stores an alpha channel value for each pallette entry. For truecolor and greyscale images it stores a single pixel value that is to be regarded as transparent.
- zTXt contains compressed text
The lowercase first letter in these chunks indicates that they're not required for the PNG specification. The lowercase last letter in some chunks indicates that they're safe to copy, even if the application concerned doesn't understand them.
PNG images can either use palette-indexed color or be made up of one or more channels (numerical values directly representing quantities about the pixels). When there is more than one channel in an image all channels have the same number of bits allocated per pixel (known as the bitdepth of the channel). Although the PNG specification always talks about the bitdepth of channels, most software and users generally talk about the total number of bits per pixel (sometimes also referred to as bitdepth or color depth).
The number of channels will depend on if the image is greyscale or color and if it has an alpha channel. PNG allows the following combinations of channels:
- greyscale and alpha (level of transparency for each pixel)
- red, green and blue (rgb/truecolor)
- red, green, blue and alpha
With indexed color images, the palette is always stored at a depth of 8 bits per channel. The palette must not have more entries than the image bitdepth allows for but it may have fewer (so if an image for example only uses 90 colors there is no need to have palette entries for all 255).
PNG offers a variety of transparency options. With truecolor and greyscale images either a single pixel value can be declared as transparent or an alpha channel can be added. For paletted images, alpha values can be added to palette entries. The number of such values stored may be less than the total number of palette entries, in which case the remaining entries are considered fully opaque.
PNG uses a non-patented lossless data compression method known as deflation. This method is combined with prediction, where for each image line, a filter method is chosen that predicts the colour of each pixel based on the colours of previous pixels and subtracts the predicted colour of the pixel from the actual color. An image line filtered in this way is often more compressible than the raw image line would be.
|bitdepth per channel||1||2||4||8||16|
|indexed (colour type 3)||1||2||4||8|
|greyscale (colour type 0)||1||2||4||8||16|
|greyscale with alpha (colour type 4)||16||32|
|truecolour (RGB - colour type 2)||24||48|
|truecolour with alpha (RGBA - colour type 6)||32||64|
Indexed color pngs are allowed to have 1, 2, 4 or 8 bits per pixel by the standard; greyscale images with no alpha channel allow for 1, 2, 4, 8 or 16 bits per pixel. Everything else uses a bitdepth per channel of either 8 or 16. The combinations this allows are given in the table on the right. The green cells with numbers represent the supported formats, the numbers inside the total bits per pixel. The red cells represent unsupported combinations. The standard requires that decoders can read all supported color formats but many image editors can only produce a small subset of them.
PNG does not offer animation. MNG is an image format that supports animation and is based on the ideas and some of the chunks of PNG but is a complex system and does not offer fallback to single image display like GIF does. APNG is another image format based on PNG that supports animation and is simpler than MNG. APNG offers fallback to single image display for PNG decoders that do not support APNG. However, as of 2005 neither of these formats is widely supported.
Technical comparison with GIFEdit
- On most images, PNG can achieve greater compression than GIF (but see the section on filesize, below).
- PNG gives a much wider range of transparency options than GIF, including alpha-channel transparency.
- PNG gives a much wider range of color depths than GIF (true color compared to 256-color), allowing for greater color precision, smoother fades etc.
- GIF supports animation while PNG does not (but see animation section, above).
Bitmap graphics editor support for PNGEdit
Note that Macromedia Fireworks uses PNG as its native file format, but this contains a lot of metadata, such as information about layers, animation, text, and effects, so should not be distributed directly in this format. Fireworks can export as an optimised PNG (without the extra metadata), for use on web-pages etc. 
Image processing programs that have PNG compression problems mainly related to lack of full implementation of the PNG compressor library
- IrfanView 3.85
- Microsoft Picture It! Photo Premium 9.
Web browser support for PNGEdit
GIF is still more widely used than PNG, partially due to misconceptions but also for several real reasons:
- On very old browsers such as Internet Explorer 3, PNG support may not be available
- GIF images support animation, which is often used in internet advertising.
The full feature set of PNG is not often used on the web, for several reasons
- Internet Explorer does not support alpha-channel transparency
- Internet Explorer 4 can crash on images containing metadata (e.g. Fireworks' native PNG file format)
The fact that Internet Explorer does not support alpha-channel transparency has led some people to erroneously believe that Internet Explorer does not support PNGs with a single transparent background color (the only kind of transparency supported by GIFs). This has also somewhat hindered the adoption of PNG.
Generally, PNG files created by a decent encoder and without unwanted metadata should be smaller than the identical image encoded in GIF format. However PNG gives the image creator far more flexibility than GIF and care needs to be taken to avoid PNG files that are needlessly large.
As GIF is limited to 256 colors, many image editors will automatically reduce the color depth when saving an image in GIF format. Therefore when people save the same truecolor image as PNG and GIF they see that the GIF is smaller (they may also see that the PNG is higher quality depending on the original image and the quality of the color reduction). They do not realise it is possible to create a 256 color PNG that has identical quality to the GIF but has a smaller filesize than the GIF, and so they develop the misconception that PNG files are larger than "equivalent" GIF files.
Another mistake that people make is to compare PNG files that contain a large amount of metadata (e.g. unoptimized PNG files from Macromedia Fireworks) to files in other formats which do not contain metadata.
Some versions of Adobe Photoshop were also reported to have very poor PNG output support which further fuelled the idea that PNG is larger than GIF.
PNG was not intended to replace the other popular web image format JPEG. JPEG will produce a smaller file than PNG for photographic images since it uses a lossy encoding method. However PNG is a better choice than JPEG for storing images that are likely to undergo further editing as jpeg suffers from generation loss issues.
- PNG Home Site
- libpng Home Page
- PNG-supporting browsers - overview of PNG status in different web browsers. First Windows IE support in 4.0b1; Netscape 4.04 .
- The Story of PNG by Greg Roelofs
- RFC 2083
- PNG transparency test
- Transparent PNG Generator
- The GD-library to generate dynamic PNG-files with PHP
- A guide to PNG optimization
- PNG as a future proof format
- PNG Adam7 interlacing