Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
5 user(s) are online (2 user(s) are browsing encyclopedia)

Members: 0
Guests: 5

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

PNG

A PNG image with an 8-bit transparency layer (top), overlayed onto a chequered background (bottom).

PNG (Portable Network Graphics) is a Lossless data compression bitmap Graphics file format. PNG was created to both improve upon and replace the GIF format with an image file format that does not require a patent license to use. PNG is officially pronounced as ping ( in International Phonetic Alphabet for English), but it is often just spelled out — possibly to avoid confusion with the internet tool Ping. PNG is supported by the libpng reference Library (computer science), a platform independent library that contains C programming language functions for handling PNG images.

PNG files nearly always use the file extensions PNG and png and are assigned the MIME media type image/png (approved on October 14 1996).

=History and development=

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 color at a time when computers capable of displaying far more than 256 colors were becoming common. Although GIF allows for computer 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 World Wide Web Consortium 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 ( . This version of PNG differs only slightly from version 1.2 and adds no new chunks.

=Technical details=

==File header==

A PNG file consists of an 8-byte magic number (programming) (89 50 4E 47 0D 0A 1A 0A in hexadecimal, which contains the letters PNG and 2 newlines, among other things [http://www.libpng.org/pub/png/spec/1.1/PNG-Rationale.html#R.PNG-file-signature]) 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 file==

PNG is structured as a series of chunks each with a size, a type, a Cyclic redundancy check, and data inside. Due to the fact that the CRC and size are at the beginning of a chunk, an encoder must either write a whole chunk at once or seek backwards (which is only possible if writing to a file, not if say sending over a network) to fill in the CRC and size after writing the data.

Chunks are given a 4 letter case sensitive name. The case of the different letters in the name provides the decoder with some information on the nature of chunks it does not recognise.

The case of the first letter indicates if the Chunk is essential or not. If the first letter is uppercase the chunk is essential if not the chunk is ancillary. Essential chunks contain information that is essential to read the file and if a decoder encounters an essential chunk it does not recognise it must abort reading the file.

The case of the second letter indicates if the chunk is public (either in the specification or the registry of special purpose public chunks) or private (not standardised). Uppercase is public and lowercase is private. This ensures that public and private chunk names can never conflict with each other.

The third letter must be uppercase to conform to the PNG specification and is reserved for future expansion. Decoders should not complain about a lower case third letter as it may be used by some future extention of the PNG sepecification.

The case of the fourth letter indicates if a chunk is safe to copy by editors that don t recognise it. If lowercase the chunk may be safely copied regardless of the extent of modifications to the file. If uppercase it may only be copied if the modifications have not touched any critical chunks.

===Essential chunks===

A decoder must be able to interpret these to read and render a PNG file.

  • IHDR must be the first chunk, it contains the header
  • PLTE contains the palette (list of colors)
  • IDAT contains the image. The image may be split among multiple IDAT chunks. Doing so increases the filesize slightly but makes it possible to generate a PNG in a streaming manner.
  • IEND marks the end of the image
  • ===Metadata chunks===

    Other image attributes that can be stored in PNG files include gamma correction values, background color, and textual Metadata information. PNG also supports color correction with the use of color management systems like sRGB color space.

  • bKGD gives the default background color
  • cHRM give the white balance
  • gAMA specified gamma
  • hIST can store the histogram, or total amount of each color in the image
  • iCCP is an ICC color profile
  • iTXt contains international (UTF-8) text either compressed or uncompressed.
  • pHYs is the physical size of the image
  • sBIT (significant bits) indicates the color-accuracy of the source data
  • sPLT suggests a palette to use if the full range of colors is not available
  • sRGB indicates that standard RGB colors are used
  • tEXt can store text that can be represented in ISO 8859-1, 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 palette entry. For truecolor and greyscale images it stores a single pixel value that is to be regarded as transparent.
  • zTXt contains compressed text with the same limitations as 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.

    ==Color depth==

    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:

    The full range of color options bitdepth per channel 1 2 4 8 16 indexed (color type 3) 1 2 4 8 greyscale (color type 0) 1 2 4 8 16 greyscale & alpha(color type 4) 16 32 truecolor(RGB - color type 2) 24 48 truecolor & alpha(RGBA - color type 6)          32 64

  • greyscale
  • 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 256).

    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.

    ==Transparency of image==

    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.

    The scanning of pixel values for binary transparency is supposed to be performed before any color reduction to avoid pixels becoming unintentionally transparent. This is most likely to pose an issue for systems that can decode 16 bits per channel images (as they must to be complient with the specification) but only output at 8 bits per channel (the norm for all but the highest end systems).

    ==Compression==

    PNG uses a non-patented lossless data compression method known as DEFLATE (algorithm). This method is combined with prediction, where for each image line, a filter method is chosen that predicts the color of each pixel based on the colors of previous pixels and subtracts the predicted color 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, especially if it is similar to the line above (since deflate has no understanding that an image is a 2D entity it just sees the image data as a stream of bytes).

    ==Interlacing==

    PNG offers an optional 2-dimensional, 7-pass interlacing scheme the Adam7 algorithm. This is more sophisticated than GIF s 1-dimensional, 4-pass scheme, and allows a clearer low-resolution image to be visible earlier in the transfer.

    ==Animation==

    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 GIF=

  • On most images, PNG can achieve greater compression than GIF (but see the #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 (truecolor compared to 256-color), allowing for greater color precision, smoother fades etc.
  • GIF supports animation while PNG does not (but see the #Animation, above).
  • =Bitmap graphics editor support for PNG=

    See main article, Comparison of bitmap graphics editors

    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. [http://www.macromedia.com/cfusion/knowledgebase/index.cfmid=tn_13871]

    Other popular graphics programs which support the PNG format are Adobe Photoshop and The Gimp, a freeware open-source image editing application available for windows, mac and unix systems.

    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 PNG=

    See main article, Comparison of web browsers#Image_format_support

    Despite campaigns such as burn all gifs [http://burnallgifs.org/], tools such as gif2png [http://www.catb.org/~esr/gif2png/], calls by the Free Software Foundation, and influential writers, PNG adoption on websites has been fairly slow.

    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 4 can crash on images containing metadata (e.g. Fireworks native PNG file format)
  • Versions of Internet Explorer up to 6 do not support native alpha-channel transparency
  • The fact that Internet Explorer does not support alpha-channel transparency has led some people to erroneously believe that Internet Explorer does not support transparency at all. However PNGs can be given a single transparent background color, which works on IE, and is equivalent to the transparency available with GIF images.

    =Filesize=

    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.

    Various tools are available for optimizing PNG files. OptiPNG and Pngcrush are both Open-source software optimizers for PNG files that can be run from a commandline in an MS-DOS window, or from a Unix or Linux commandline, and are very effective at reducing the size of PNG files for the web, especially those exported from Adobe Photoshop (versions prior to CS) and other graphics packages. Other tools such as [http://advsys.net/ken/utils.htm PNGOut] and [http://advancemame.sourceforge.net/comp-readme.html AdvanceCOMP] can also reduce the size of PNG files even more and thus, give the user the smallest file size possible for a given PNG image.

    PNG was not intended to replace the other popular web image format JPEG. See the #Comparison with JPEG section below for more details on how the two formats compare.

    =Comparison with JPEG=

    JPEG will produce a smaller file than PNG for photographic (and photo like) images since it uses a lossy encoding method specifically designed for photographic image data. Using PNG instead of a high quality JPEG for such images would result in a large increase in filesize (often 5-10 times) with negligable gain in quality. Whilst this may be acceptable to those with fast unmetered connections it is unlikely to be acceptable to users who use dialup connections or to website owners who pay by the amount of data transferred.

    PNG is a better choice than JPEG for storing images that contain text, line art, or other images with sharp transitions that don t transform well into the frequency domain. Where an image contains both sharp transitions and photographic parts a choice must be made between the large but sharp PNG and JPEG artifacts around sharp transitions.

    Finally, PNG is useful as a lossless format for images that are likely to undergo further editing and may need to be distributed in that lossless form, since it uses a better compression algorithm and is better supported than TIFF. JPEG is a poor choice for storing images that may need to be edited further as it suffers from generation loss issues.

    =See also=

    *Digital image editing *Computer Graphics, including: **Comparison of layout engines (graphics) *Related graphics file formats **APNG **JNG **MNG *Image file formats

    =External links=

    ==libpng.org==

    *[http://www.libpng.org/pub/png/ PNG Home Site] *[http://www.libpng.org/pub/png/libpng.html libpng Home Page] *[http://www.libpng.org/pub/png/pngapbr.html PNG-supporting browsers] - overview of PNG status in different web browsers. First Windows IE support in 4.0b1; Netscape 4.04 [http://oregon.usgs.gov/png_images.html]. *[http://www.libpng.org/pub/png/slashpng-1999.html The Story of PNG by Greg Roelofs] *[http://www.libpng.org/pub/png/book/ PNG: The Definitive Guide (Online Version) by Greg Roelofs]

    ==W3C==

    *[http://www.w3.org/TR/2003/REC-PNG-20031110/ PNG Specification (Second Edition), W3C Recommendation 10 November 2003] *[http://www.w3.org/Graphics/PNG/Inline-img.html Test inline PNG images]

    ==Others==

    *RFC 2083 *[http://entropymine.com/jason/testbed/pngtrans/ PNG transparency test] *[http://apps.everamber.com/alpha/ Transparent PNG Generator] *[http://php.net/gd The GD-library to generate dynamic PNG-files with PHP] *[http://www.cs.toronto.edu/~cosmin/pngtech/optipng.html A guide to PNG optimization] *[http://en.wikibooks.org/wiki/How_to_future_proof_electronic_information#Images_.26_Photos_.28Raster_Graphics.29 PNG as a future proof format] *[http://schaik.com/png/adam7.html PNG Adam7 interlacing] *[http://www.compression-links.info/PNG List of PNG-related resources, libraries and papers]

    ==Browser incompatibilities==

    *[http://support.microsoft.com/default.aspxscid=kb;en-us;294714 PNG Files Do Not Show Transparency in Internet Explorer] *[http://homepage.ntlworld.com/bobosola/ The PNG problem in Windows Internet Explorer] *[http://www.nrkn.com/alpha/ png transparency in IE]