(PNG, pronounced “PING”) (n.) An extensible file format for lossless, compressed storage of images. PNG is recommended by the World Wide Web Consortium (W3C) as an Internet Media Type (image/png) to replace GIF, and it may effectively replace TIFF as well. PNG supports indexed-color, grayscale, and true color images, along with an optional alpha channel. The sample depth may vary from 1 to 16 bits. PNG may be streamed on the Internet with a progressive display option. It provides file integrity checking and simple detection of common transmission errors. PNG stores gamma and chromaticity for color matching on heterogeneous platforms.
Like GIF, PNG can index up to 256 colors, streaming progressive display, transparent layers, platform independence, and totally lossless compression. The unique features of PNG are true color (up to 48 bits per pixel), grayscale (up to 16 bits per pixel), full alpha channel (general transparency masks), image gamma information, and detection of file corruption.
GIF is copyrighted and lacks some desirable features. PNG provides an image format in the public domain that exceeds the limitations of GIF. PNG exhibits highly flexible transparency, compression efficiency, and resistance to transmission errors. Images transferred on the Internet are sometimes processed as text by mistake, which may cause file corruption. PNG is designed so that such errors can be detected quickly and reliably.
The PNG specification exhibits some carefully calculated limitations of its own. There is neither lossy compression nor an uncompressed variant of PNG. The format does not support multiple images in one file or CMYK color space. There is not a standard chunk specified for thumbnail views. Such features could be accomplished if the basic specification were extended. PNG uses network byte order consistently, so that files may be converted on any platform that supports TCP/IP and on all PC platforms.
PNG uses a two-dimensional interlacing scheme that is more complex than the linewise interlacing of GIF. The PNG file is slightly bigger, but it draws an initial image eight times faster than GIF. Although that initial image is coarser, PNG completely renders it more quickly. Horizontal and vertical resolution never differ by more than a factor of two, and text in an interlaced PNG is readable much sooner than in an equivalent GIF image.
The variety of images and display systems used for the web creates images that are too dark or light. PNG assumes that image viewing software will compensate for image gamma whenever the image is displayed. The viewer will appropriately adjust images with no gamma or with an incorrect recorded gamma for the delivery system. PNG employs “unassociated” or “nonpremultiplied” alpha, so that images with separate transparency masks may be stored without loss of data.
Filtering can reduce the compressed size of true color and grayscale images, so PNG includes a filtering capability. The filter algorithms operate on bytes rather than on pixels because filtering is usually ineffective on images with fewer than eight bits per sample. The encoder is allowed to change filters for each new scan line because adaptive filtering outperforms fixed filters and adds little to the compressed file size. This process maximizes the quality of each scan line.
PNG allows some textual information to be stored along with the graphical data. Textual information should be stored in standard tEXt chunks with suitable keywords. Use of tEXt tells a PNG viewer that the chunk contains related text. Latin-1 is the recommended text format for these chunks because it is a direct subset of character sets commonly used on popular platforms such as Microsoft Windows and X Window System.
The values in the first 8 bytes of a PNG file are shown in the table below.
Values Contained in the First 8 Bytes of a PNG File
|Byte 1||Byte 2||Byte 3||Byte 4||Byte 5||Byte 6||Byte 7||Byte 8|
This byte order allows common file transfer problems to be detected immediately. The first 2 bytes distinguish PNG files on systems that expect the first 2 bytes to identify the file type uniquely. The first byte is a non-ASCII value, which reduces the probability that a text file may be incorrectly identified as a PNG file. The byte order also catches bad file transfers that clear bit 7. Bytes 2 through 4 name the format. The carriage return line feed (CRLF) sequence catches bad file transfers that alter new-line sequences. The Ctrl-Z character stops file display under MS-DOS. The final line feed checks for the inverse of the CRLF translation problem.
Chunk length is limited to avoid problems for systems that cannot handle four-byte unsigned values. A separate cyclic redundancy check (CRC) is provided for each chunk in order to detect transfer errors rapidly and to validate data. If a viewer does not provide as many colors as are listed in the palette belonging to an image, a palette histogram provides the information needed to select a target palette.
Virtually all browsers can process and view PNG files, and most graphics-processing packages are capable of encoding in this highly recommended format. It is assumed that web developers will embrace PNG as superior to other compression formats.