|
PNG (Portable Network Graphics) is a bitmap image format that employs lossless data compression. 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 IPA), but it is often just spelled out — possibly to avoid confusion with the network tool ping. PNG is supported by the libpng reference library, a platform-independent library that contains C functions for handling PNG images. PNG supports palette based (with a palette defined in terms of the 24 bit RGB colors), greyscale and RGB images. PNG was designed for distribution of images on the internet not for professional graphics and as such other color spaces (such as CMYK) are not supported. PNG files nearly always use the file extension PNG or 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 announced that it would be enforcing software patents on the LZW data compression algorithm used in the GIF format (the acronym PNG was originally recursive, standing for "PNG's Not GIF" *. For more on this controversy see GIF (Unisys and LZW patent enforcement). 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 colors 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. File header A PNG file starts with an 8-byte signature. The hexadecimal byte values are 89 50 4E 47 0D 0A 1A 0A. Each of the header bytes is there for a specific reason *: "Chunks" within the file After the header come a series 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. The chunks each have a header specifying their size and type. This is immediately followed by the actual data, and then the checksum of 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 necessary to read the file. 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. It is reserved for future expansion. The case of the fourth letter indicates if a chunk is safe to copy by editors that do not 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. Metadata chunks Other image attributes that can be stored in PNG files include gamma values, background color, and textual metadata information. PNG also supports color management through the inclusion of ICC color space profiles. The lowercase first letter in these chunks indicates that they are not needed for the PNG specification. The lowercase last letter in some chunks indicates that they are safe to copy, even if the application concerned does not understand them. Colour 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 whether the image is greyscale or color and whether it has an alpha channel. PNG allows the following combinations of channels: 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 above. 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 compliant 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 deflation. 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, and instead 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. However, as a 7-pass scheme, it tends to reduce the data's compressibility more than simpler schemes. 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 neither of these formats are widely supported. Technical comparison with GIF Bitmap graphics editor support for PNG Macromedia Fireworks uses PNG as its native file format but by default also stores metadata for layers, animation, text and effects. Such files should not be distributed directly. Fireworks can instead export as an optimised PNG without the extra metadata for use on webpages etc.* Other popular graphics programs which support the PNG format include Adobe Photoshop, Pixel image editor, The GIMP and GraphicConverter. Programs that support PNG and are bundled with popular operating systems include Microsoft's Paint and Apple's iPhoto. Some image processing programs have PNG compression problems, mainly related to lack of full implementation of the PNG compressor library: Web browser support for PNG Despite campaigns such as "burn all gifs" *, tools such as 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 more accurate reasons: The full feature set of PNG is not often used on the web, for several reasons: The fact that Internet Explorer 4.0-6.0 did 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. There are also a number of methods using DirectX functions in style sheets and HTML that can make Internet Explorer display full transparency data in PNG images on web pages. Internet Explorer also renders PNGs in a slightly incorrect color gamut. If a GIF and PNG image of several colors are placed side-by-side on a page, a user can often see a slight difference in color. While accurate color can never be guaranteed due to monitor and other computer differences among users, it can cause difficulty to web designers attempting to use several image formats on a page where color matching is important. There is an interesting partial fix * using a PHP script which utilizes the GD Graphics Library (phpGD) to alter PNG images to display correctly in affected versions of Internet Explorer. Internet Explorer 7.0 has addressed the PNG-rendering issues, and now displays them correctly. Apple's Safari, Mozilla Firefox, and Opera have full PNG compatibility. For the complete comparison, see Comparison of web browsers#Image format support. File size and optimization software
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 negligible gain in quality. PNG is a better choice than JPEG for storing images that contain text, line art, or other images with sharp transitions that do not 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 a small JPEG with artifacts around sharp transitions. JPEG is a poor choice for storing images that require further editing as it suffers from generation loss, whereas lossless formats do not. This makes PNG useful for saving temporary photographs that require successive editing. When the photograph is ready to be distributed, it can then be saved as a JPEG, and this limits the information loss to just one generation. That said, PNG does not support Exif image data from sources such as digital cameras, which makes it problematic for use amongst amateur and especially professional photographers. TIFF does support it as a lossless format, but is much larger in file size for an equivalent image. JPEG has historically been the format of choice for exporting images containing gradients, as it could handle the color depth much better than the GIF format. However, any compression by the JPEG would cause the gradient to become blurry, but a 24-bit PNG export of a gradient image often comes out identical to the source vector image, and at a small file size. As such, the PNG format is the optimal choice for exporting small, repeating gradients for web usage. Comparison with TIFF TIFF is a complicated format that incorporates an extremely wide range of options. While this makes it useful as a generic format for interchange between professional image editing applications, it makes supporting it in more general applications such as Web browsers difficult. It also means that many applications can only read a subset of TIFF types creating more potential user confusion. The most common general-purpose lossless compression algorithm used with TIFF is LZW, which is inferior to PNG and until expiration in 2003 suffered from the same patent issues that GIF did. There is an option to use the same compression algorithm with TIFF as PNG uses, but it is not supported by many proprietary programs. TIFF also offers special-purpose lossless compression algorithms like CCITT Group IV, which can compress black and white text better than PNG's compression algorithm. See also libpng.org W3C Others Internet Explorer incompatibility | |||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||
![]() |
|
| |