PNG
Encyclopedia
Portable Network Graphics (PNG icon) is a bitmapped
Raster graphics
In computer graphics, a raster graphics image, or bitmap, is a data structure representing a generally rectangular grid of pixels, or points of color, viewable via a monitor, paper, or other display medium...

 image format that employs lossless data compression
Lossless data compression
Lossless data compression is a class of data compression algorithms that allows the exact original data to be reconstructed from the compressed data. The term lossless is in contrast to lossy data compression, which only allows an approximation of the original data to be reconstructed, in exchange...

. PNG was created to improve upon and replace GIF (Graphics Interchange Format) as an image-file format not requiring a patent
Patent
A patent is a form of intellectual property. It consists of a set of exclusive rights granted by a sovereign state to an inventor or their assignee for a limited period of time in exchange for the public disclosure of an invention....

 license. The initialism PNG can also be interpreted as a recursive initialism for "PNG's Not GIF".

PNG supports palette-based images (with palettes of 24-bit RGB
RGB color model
The RGB color model is an additive color model in which red, green, and blue light is added together in various ways to reproduce a broad array of colors...

 or 32-bit RGBA colors), grayscale
Grayscale
In photography and computing, a grayscale or greyscale digital image is an image in which the value of each pixel is a single sample, that is, it carries only intensity information...

 images (with or without alpha channel), and RGB[A] images (with or without alpha channel). PNG was designed for transferring images on the Internet, not for professional-quality print graphics, and therefore does not support non-RGB color space
Color space
A color model is an abstract mathematical model describing the way colors can be represented as tuples of numbers, typically as three or four values or color components...

s such as CMYK
CMYK color model
The CMYK color model is a subtractive color model, used in color printing, and is also used to describe the printing process itself. CMYK refers to the four inks used in some color printing: cyan, magenta, yellow, and key...

.

PNG files nearly always use file extension PNG or png and are assigned MIME media type image/png; it was approved for this use by the Internet Engineering Steering Group
Internet Engineering Steering Group
The Internet Engineering Steering Group is a body composed of the Internet Engineering Task Force chair and area directors.It provides the final technical review of Internet standards and is responsible for day-to-day management of the IETF...

 on October 14, 1996. PNG was published as an ISO/IEC standard in 2004.

History and development

The motivation for creating the PNG format was in early 1995, after it became known that the Lempel–Ziv–Welch (LZW) data compression
Data compression
In computer science and information theory, data compression, source coding or bit-rate reduction is the process of encoding information using fewer bits than the original representation would use....

 algorithm used in the Graphics Interchange Format (GIF) format was patent
Patent
A patent is a form of intellectual property. It consists of a set of exclusive rights granted by a sovereign state to an inventor or their assignee for a limited period of time in exchange for the public disclosure of an invention....

ed by Unisys
Unisys
Unisys Corporation , headquartered in Blue Bell, Pennsylvania, United States, and incorporated in Delaware, is a long established business whose core products now involves computing and networking.-History:...

. There were also other problems with the GIF format that made a replacement desirable, notably its limit of 256 color
Color
Color or colour is the visual perceptual property corresponding in humans to the categories called red, green, blue and others. Color derives from the spectrum of light interacting in the eye with the spectral sensitivities of the light receptors...

s at a time when computers able to display far more than 256 colors were growing common. Although GIF allows for animation
Computer animation
Computer animation is the process used for generating animated images by using computer graphics. The more general term computer generated imagery encompasses both static scenes and dynamic images, while computer animation only refers to moving images....

, it was decided that PNG should be a single-image format. A companion format called Multiple-image Network Graphics (MNG) has been defined for animation, whereas a competing format, Animated Portable Network Graphics (APNG)
APNG
The Animated Portable Network Graphics file format is an unofficial extension to the Portable Network Graphics specification. It allows for animated PNG files that work similarly to animated GIF files, while supporting 24-bit images and 8-bit transparency not available for GIFs...

, supports backward-compatibility with PNG (which MNG does not).

A January 1995 precursory discussion thread, on the usenet newsgroup "comp.graphics" with the subject Thoughts on a GIF-replacement file format, had many propositions, which would later be part of the PNG file format. In this thread, Oliver Fromme, author of the popular DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

 JPEG
JPEG
In computing, JPEG . The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality. JPEG typically achieves 10:1 compression with little perceptible loss in image quality....

 viewer QPEG
QPEG
# Is a video codec created by Q-Team that uses run-length encoding, interframe differencing and motion compensation .# It was also a popular image viewer in the early 1990s, for the obsolete MS-DOS operating system.- External links :...

, proposed the PING name, meaning PING is not GIF, and also the PNG extension.
  • October 1, 1996: Version 1.0 of the PNG specification was released, and later appeared as RFC
    Request for Comments
    In computer network engineering, a Request for Comments is a memorandum published by the Internet Engineering Task Force describing methods, behaviors, research, or innovations applicable to the working of the Internet and Internet-connected systems.Through the Internet Society, engineers and...

     2083. It became a W3C
    World Wide Web Consortium
    The World Wide Web Consortium is the main international standards organization for the World Wide Web .Founded and headed by Tim Berners-Lee, the consortium is made up of member organizations which maintain full-time staff for the purpose of working together in the development of standards for the...

     Recommendation on October 1, 1996.
  • December 31, 1998: Version 1.1, with some small changes and the addition of three new chunks, was released.
  • August 11, 1999: Version 1.2, adding one extra chunk, was released.
  • November 10, 2003: PNG became an International Standard (ISO
    International Organization for Standardization
    The International Organization for Standardization , widely known as ISO, is an international standard-setting body composed of representatives from various national standards organizations. Founded on February 23, 1947, the organization promulgates worldwide proprietary, industrial and commercial...

    /IEC
    International Electrotechnical Commission
    The International Electrotechnical Commission is a non-profit, non-governmental international standards organization that prepares and publishes International Standards for all electrical, electronic and related technologies – collectively known as "electrotechnology"...

     15948:2003). This version of PNG differs only slightly from version 1.2 and adds no new chunks.
  • March 3, 2004: ISO/IEC 15948:2004.

PNG Working Group

The original PNG specification was authored by an ad-hoc group of computer graphics experts and enthusiasts. Discussions and decisions about the format were done exclusively via email. The original authors listed on RFC 2083 are:
  • Editor: Thomas Boutell
  • Contributing Editor: Tom Lane
  • Authors (in alphabetical order): Mark Adler
    Mark Adler
    Dr. Mark Adler may be best known for his work in the field of data compression. Adler is the author of the Adler-32 hash function, a co-author of the zlib compression library and gzip, has contributed to Info-ZIP, and has participated in developing the Portable Network Graphics image format...

    , Thomas Boutell, Christian Brunschen, Adam M. Costello, Lee Daniel Crocker, Andreas Dilger, Oliver Fromme, Jean-loup Gailly
    Jean-Loup Gailly
    Jean-Loup Gailly - is an author of gzip. He wrote the compression code of the portable archiver of the Info-ZIP and the tools compatible with the PKZIP archiver for MS-DOS...

    , Chris Herborth, Aleks Jakulin, Neal Kettler, Tom Lane, Alexander Lehmann, Chris Lilley, Dave Martindale, Owen Mortensen, Keith S. Pickens, Robert P. Poole, Glenn Randers-Pehrson, Greg Roelofs, Willem van Schaik, Guy Schalnat, Paul Schmidt, Tim Wegner, Jeremy Wohl

Technical details

File header

A PNG file starts with an 8-byte
Byte
The byte is a unit of digital information in computing and telecommunications that most commonly consists of eight bits. Historically, a byte was the number of bits used to encode a single character of text in a computer and for this reason it is the basic addressable element in many computer...

 signature. The hexadecimal
Hexadecimal
In mathematics and computer science, hexadecimal is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F to represent values ten to fifteen...

 byte values are 89 50 4E 47 0D 0A 1A 0A; the decimal values are 137 80 78 71 13 10 26 10. Each of the header bytes is there for a specific reason:
Bytes Purpose
89 Has the high bit set to detect transmission systems that do not support 8 bit data
8-bit clean
8-bit clean describes a computer system that correctly handles 8-bit character sets, such as the ISO 8859 series and the UTF-8 encoding of Unicode.- History :...

 and to reduce the chance that a text file is mistakenly interpreted as a PNG, or vice versa.
50 4E 47 In ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

, the letters PNG, allowing a person to identify the format easily if it is viewed in a text editor.
0D 0A A DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

-style line ending
Newline
In computing, a newline, also known as a line break or end-of-line marker, is a special character or sequence of characters signifying the end of a line of text. The name comes from the fact that the next character after the newline will appear on a new line—that is, on the next line below the...

 (CRLF) to detect DOS-Unix line ending conversion of the data.
1A A byte that stops display of the file under DOS when the command type
Type (command)
In computing, type is a command in various VMS. AmigaDOS, CP/M, DOS, OS/2 and Microsoft Windows command line interpreters such as COMMAND.COM, cmd.exe, 4DOS/4NT and Windows PowerShell. It is used to display the contents of specified files...

 has been used—the end-of-file
End-of-file
In computing, end of file is a condition in a computer operating system where no more data can be read from a data source...

 character
0A A Unix-style line ending (LF) to detect Unix-DOS line ending conversion.

"Chunks" within the file

After the header comes a series of chunks
Chunk (information)
A chunk is a fragment of information which is used in many multimedia formats, such as PNG, MP3 and AVI.Each chunk contains a header which indicates some parameters A chunk is a fragment of information which is used in many multimedia formats, such as PNG, MP3 and AVI.Each chunk contains a header...

, 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 storage layer structure, similar in concept to a container format, is designed to allow the PNG format to be extended while maintaining compatibility with older versions—it provides forward compatibility
Forward compatibility
Forward compatibility or upward compatibility is a compatibility concept for systems design, as e.g. backward compatibility. Forward compatibility aims at the ability of a design to gracefully accept input intended for later versions of itself...

, and this same file structure (with different signature and chunks) is used in the associated MNG
MNG
Multiple-image Network Graphics is a public graphics file format for animated images.MNG is closely related to the PNG image format. When PNG development started in early 1995, developers decided not to incorporate support for animation, not least because this feature of GIF was seldom used at the...

, JNG
JNG
JPEG Network Graphics is a JPEG-based graphics file format which is closely related to PNG: it uses the PNG file structure as a container format to wrap JPEG encoded image data....

, and APNG
APNG
The Animated Portable Network Graphics file format is an unofficial extension to the Portable Network Graphics specification. It allows for animated PNG files that work similarly to animated GIF files, while supporting 24-bit images and 8-bit transparency not available for GIFs...

 formats.

A chunk consists of four parts: length (4 bytes), chunk type/name (4 bytes), chunk data (length bytes) and CRC
Cyclic redundancy check
A cyclic redundancy check is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data...

 (cyclic redundancy code/checksum; 4 bytes).
Length Chunk type Chunk data CRC
4 bytes 4 bytes Length bytes 4 bytes


Chunks are given a four letter case sensitive
Case sensitivity
Text sometimes exhibits case sensitivity; that is, words can differ in meaning based on differing use of uppercase and lowercase letters. Words with capital letters do not always have the same meaning when written with lowercase letters....

 ASCII type/name; compare FourCC
FourCC
A FourCC is a sequence of four bytes used to uniquely identify data formats.The concept originated in the OSType scheme used in the Macintosh system software and was adopted for the Amiga/Electronic Arts Interchange File Format and derivatives...

. The case of the different letters in the name (bit 5 of the numeric value of the character) is a bit field
Bit field
A bit field is a common idiom used in computer programming to compactly store multiple logical values as a short series of bits where each of the single bits can be addressed separately. A bit field is most commonly used to represent integral types of known, fixed bit-width. A well-known usage of...

 that provides the decoder
Decoder
A decoder is a device which does the reverse operation of an encoder, undoing the encoding so that the original information can be retrieved. The same method used to encode is usually just reversed in order to decode...

 with some information on the nature of chunks it does not recognize.

The case of the first letter indicates if the chunk is critical or not. If the first letter is uppercase, the chunk is critical; if not, the chunk is ancillary. Critical chunks contain information that is necessary to read the file. If a decoder encounters a critical chunk it does not recognize, it must abort reading the file or supply the user with an appropriate warning.

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 (although two private chunk names could conflict).

The third letter must be uppercase to conform to the PNG specification. It is reserved for future expansion. Decoders should treat a chunk with a lower case third letter the same as any other unrecognised chunk.

The case of the fourth letter indicates if a chunk is safe to copy by editors that do not recognize 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.

Critical 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
    Palette (computing)
    In computer graphics, a palette is either a given, finite set of colors for the management of digital images , or a small on-screen graphical element for choosing from a limited set of choices, not necessarily colors .Depending on the context In computer graphics, a palette is either a given,...

    ; list of colors.
  • IDAT contains the image, which may be split among multiple IDAT chunks. Doing so increases filesize slightly, but makes it possible to generate a PNG in a streaming manner.
  • IEND marks the image end.

The PLTE chunk is essential for color type 3 (indexed color). It is optional for color types 2 and 6 (truecolor and truecolor with alpha) and it must not appear for color types 0 and 4 (grayscale and grayscale with alpha).

Ancillary chunks

Other image attributes that can be stored in PNG files include gamma
Gamma correction
Gamma correction, gamma nonlinearity, gamma encoding, or often simply gamma, is the name of a nonlinear operation used to code and decode luminance or tristimulus values in video or still image systems...

 values, background color, and textual metadata
Metadata
The term metadata is an ambiguous term which is used for two fundamentally different concepts . Although the expression "data about data" is often used, it does not apply to both in the same way. Structural metadata, the design and specification of data structures, cannot be about data, because at...

 information. PNG also supports color management
Color management
In digital imaging systems, color management is the controlled conversion between the color representations of various devices, such as image scanners, digital cameras, monitors, TV screens, film printers, computer printers, offset presses, and corresponding media.The primary goal of color...

 through the inclusion of ICC
International Color Consortium
The International Color Consortium was formed in 1993 by eight industry vendors in order to create a universal color management system that would function transparently across all operating systems and software packages....

 color space
Color space
A color model is an abstract mathematical model describing the way colors can be represented as tuples of numbers, typically as three or four values or color components...

 profiles.
  • bKGD gives the default background color. It is intended for use when there is no better choice available, such as in standalone image viewers (but not web browsers; see below for more details).
  • cHRM gives the chromaticity
    Chromaticity
    Chromaticity is an objective specification of the quality of a color regardless of its luminance, that is, as determined by its hue and colorfulness ....

     coordinates of the display primaries
    Primary Colors
    Primary Colors: A Novel of Politics is a roman à clef, a work of fiction that purports to describe real life characters and events — namely, Bill Clinton's first presidential campaign in 1992...

     and white point
    White point
    A white point is a set of tristimulus values or chromaticity coordinates that serve to define the color "white" in image capture, encoding, or reproduction. Depending on the application, different definitions of white are needed to give acceptable results...

    .
  • gAMA specifies gamma
    Gamma correction
    Gamma correction, gamma nonlinearity, gamma encoding, or often simply gamma, is the name of a nonlinear operation used to code and decode luminance or tristimulus values in video or still image systems...

    .
  • hIST can store the histogram, or total amount of each color in the image.
  • iCCP is an ICC color profile.
  • iTXt contains UTF-8
    UTF-8
    UTF-8 is a multibyte character encoding for Unicode. Like UTF-16 and UTF-32, UTF-8 can represent every character in the Unicode character set. Unlike them, it is backward-compatible with ASCII and avoids the complications of endianness and byte order marks...

     text, compressed or not, with an optional language tag. iTXt chunk with the keyword 'XML:com.adobe.xmp' can contain Extensible Metadata Platform
    Extensible Metadata Platform
    The Adobe Extensible Metadata Platform is a standard, created by Adobe Systems Inc., for processing and storing standardized and proprietary information relating to the contents of a file....

     (XMP).
  • pHYs holds the intended pixel size and/or aspect ratio
    Aspect ratio
    The aspect ratio of a shape is the ratio of its longer dimension to its shorter dimension. It may be applied to two characteristic dimensions of a three-dimensional shape, such as the ratio of the longest and shortest axis, or for symmetrical objects that are described by just two measurements,...

     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 unavailable.
  • sRGB indicates that the standard sRGB color space
    SRGB color space
    sRGB is a standard RGB color space created cooperatively by HP and Microsoft in 1996 for use on monitors, printers, and the Internet.sRGB uses the ITU-R BT.709 primaries, the same as are used in studio monitors and HDTV, and a transfer function typical of CRTs...

     is used.
  • sTER stereo-image indicator chunk for stereoscopic images
  • tEXt can store text that can be represented in ISO/IEC 8859-1
    ISO/IEC 8859-1
    ISO/IEC 8859-1:1998, Information technology — 8-bit single-byte coded graphic character sets — Part 1: Latin alphabet No. 1, is part of the ISO/IEC 8859 series of ASCII-based standard character encodings, first edition published in 1987. It is informally referred to as Latin-1. It is generally...

    , with one name=value pair for each chunk.
  • tIME stores the time that the image was last changed.
  • tRNS contains transparency information. For indexed images, it stores alpha channel values for one or more palette entries. For truecolor and grayscale images, it stores a single pixel value that is to be regarded as fully transparent.
  • zTXt contains compressed text with the same limits as tEXt.


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.

Color depth

PNG color options
Bits per pixel Bits per channel
Color option Channels 1 2 4 8 16
Indexed 1
}
|-
! Grayscale
! 1
| || || || ||
|-
! Grayscale & alpha
! 2
| || || || ||
|-
! Truecolor
! 3
| || || || ||
|-
! Truecolor & alpha
! 4
| || || || ||
|}

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 bit depth
Color depth
In computer graphics, color depth or bit depth is the number of bits used to represent the color of a single pixel in a bitmapped image or video frame buffer. This concept is also known as bits per pixel , particularly when specified along with the number of bits used...

 of the channel). Although the PNG specification always talks about the bit depth of channels, most software and users generally talk about the total number of bits per pixel (sometimes also referred to as bit depth or color depth
Color depth
In computer graphics, color depth or bit depth is the number of bits used to represent the color of a single pixel in a bitmapped image or video frame buffer. This concept is also known as bits per pixel , particularly when specified along with the number of bits used...

). Since multiple channels can affect a single pixel, the number of bits per pixel is often higher than the number of bits per channel, as shown in the illustration at right.

The number of channels will depend on whether the image is grayscale or color and whether it has an alpha channel. PNG allows the following combinations of channels, called the color type.

The color type is specified in the color type field, which is a bit field
Bit field
A bit field is a common idiom used in computer programming to compactly store multiple logical values as a short series of bits where each of the single bits can be addressed separately. A bit field is most commonly used to represent integral types of known, fixed bit-width. A well-known usage of...

, as explained in the table below at right. Not all combinations are valid, however: there is no indexed grayscale, which would be color types 1 and 5; transparency in palette images is indicated by the presence of a tRNS chunk, not a separate channel, so there is no color type 7.
PNG color types
Color
type
Name Binary Masks
  A C P
0 Grayscale  
1 Indexed grayscale palette
2 Truecolor color
3 Indexed palette
4 Grayscale & alpha alpha
5 Indexed grayscale & alpha palette
6 Truecolor & alpha color
7 Indexed & alpha color | palette
  • grayscale
  • red, green and blue: rgb/truecolor
  • indexed: channel containing indices into a palette of colors
  • grayscale and alpha: level of transparency for each pixel
  • red, green, blue and alpha


With indexed color images, the palette is always stored in RGB at a depth of 8 bits per channel (24 bits per palette entry). Additionally, an optional array of 8-bit alpha values of the palette entries may be included. The palette must not have more entries than the image bit depth allows for, but it may have fewer (for example, if an image only uses 90 colors then it does not need palette entries for all 256 colors).

Indexed color PNGs are allowed to have 1, 2, 4 or 8 bits per pixel by the standard; grayscale images with no alpha channel allow for 1, 2, 4, 8 or 16 bits per pixel. Everything else uses a bit depth 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 grayscale images either a single pixel value can be declared as transparent or an alpha channel can be added (enabling any percentage of partial transparency to be used). 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 2-stage compression process:
  • pre-compression: filtering (prediction)
  • compression: DEFLATE


PNG uses a non-patented lossless data compression
Lossless data compression
Lossless data compression is a class of data compression algorithms that allows the exact original data to be reconstructed from the compressed data. The term lossless is in contrast to lossy data compression, which only allows an approximation of the original data to be reconstructed, in exchange...

 method known as DEFLATE
DEFLATE
Deflate is a lossless data compression algorithm that uses a combination of the LZ77 algorithm and Huffman coding. It was originally defined by Phil Katz for version 2 of his PKZIP archiving tool and was later specified in RFC 1951....

, which is the same algorithm used in the zlib
Zlib
zlib is a software library used for data compression. zlib was written by Jean-Loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compression program. Zlib is also a crucial component of many software platforms including Linux, Mac OS X,...

 compression library.

Filtering

Before DEFLATE is applied, the data is precompressed, via a prediction method: a single filter method is used for the entire image, while for each image line, a filter type is chosen that transforms the data so that it is hopefully more easily compressed.

There is only one filter method in the current PNG specification (denoted method 0), and thus in practice the only choice is which filter type to apply to each line. For this method, the filter predicts the value of each pixel based on the values of previous neighboring pixels, and subtracts the predicted color of the pixel from the actual value, as in DPCM
DPCM
Differential pulse-code modulation is a signal encoder that uses the baseline of pulse-code modulation but adds some functionalities based on the prediction of the samples of the signal...

. 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 the differences from prediction will generally be clustered around 0, rather than spread over all possible image values. This is particularly important in relating separate rows, since DEFLATE has no understanding that an image is a 2D entity, and instead just sees the image data as a stream of bytes.

There are five filter types for filter method 0; each type predicts the value of each byte (of the image data before filtering) based on the corresponding byte of the pixel to the left (A), above (B), above and to the left (C) or some combination thereof, and encodes the difference between the predicted value and the actual value. Filters are applied to byte values, not pixels; pixel values may be one or two bytes, or several values per byte, but never cross byte boundaries. The filter types are:
Type byte Filter name Predicted value
0 None Zero (so that the raw byte value passes through unaltered)
1 Sub Byte A (to the left)
2 Up Byte B (above)
3 Average Mean of bytes A and B, rounded down
4 Paeth A, B, or C, whichever is closest to

The Paeth filter is based on an algorithm by Alan W. Paeth.
Compare to the version of DPCM
DPCM
Differential pulse-code modulation is a signal encoder that uses the baseline of pulse-code modulation but adds some functionalities based on the prediction of the samples of the signal...

 used in lossless JPEG, and to the discrete wavelet transform
Discrete wavelet transform
In numerical analysis and functional analysis, a discrete wavelet transform is any wavelet transform for which the wavelets are discretely sampled...

 using 1×2, 2×1, or (for the Paeth predictor) 2×2 windows and Haar wavelet
Haar wavelet
In mathematics, the Haar wavelet is a certain sequence of rescaled "square-shaped" functions which together form a wavelet family or basis. Wavelet analysis is similar to Fourier analysis in that it allows a target function over an interval to be represented in terms of an orthonormal function basis...

s.

Compression is further improved by choosing filter types adaptively on a line-by-line basis. This improvement, and a heuristic method of implementing it commonly used by PNG-writing software, were created by Lee Daniel Crocker, who tested the methods on many images during the creation of the format; the choice of filter is a component of file size optimization, as discussed below.

If interlacing is used, each stage of the interlacing is filtered separately, meaning that the image can be progressively rendered as each stage is received; however, interlacing generally makes compression less effective.

Interlacing

PNG offers an optional 2-dimensional, 7-pass interlacing scheme—the Adam7 algorithm
Adam7 algorithm
Adam7 is an interlacing algorithm for raster images, best known as the interlacing scheme optionally used in PNG images. An Adam7 interlaced image is broken into seven subimages, which are defined by replicating this 8×8 pattern across the full image....

. 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, particularly if interpolation algorithms such as bicubic interpolation
Bicubic interpolation
In mathematics, bicubic interpolation is an extension of cubic interpolation for interpolating data points on a two dimensional regular grid. The interpolated surface is smoother than corresponding surfaces obtained by bilinear interpolation or nearest-neighbor interpolation...

 are used.

However, the 7-pass scheme tends to reduce the data's compressibility more than simpler schemes.

Animation

PNG itself does not support animation at all. MNG is an extension to PNG that does; it was designed by members of the PNG Group. MNG shares PNG's basic structure and chunks, but it is significantly more complex and has a different file signature, which automatically renders it incompatible with standard PNG decoders.

The complexity of MNG led to the proposal of APNG
APNG
The Animated Portable Network Graphics file format is an unofficial extension to the Portable Network Graphics specification. It allows for animated PNG files that work similarly to animated GIF files, while supporting 24-bit images and 8-bit transparency not available for GIFs...

 by developers of the Mozilla Foundation. It is based on PNG, 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 is currently widely supported. APNG is supported in Firefox
Mozilla Firefox
Mozilla Firefox is a free and open source web browser descended from the Mozilla Application Suite and managed by Mozilla Corporation. , Firefox is the second most widely used browser, with approximately 25% of worldwide usage share of web browsers...

 3.0 and Opera
Opera (web browser)
Opera is a web browser and Internet suite developed by Opera Software with over 200 million users worldwide. The browser handles common Internet-related tasks such as displaying web sites, sending and receiving e-mail messages, managing contacts, chatting on IRC, downloading files via BitTorrent,...

 9.5. The PNG Group decided in April 2007 not to embrace APNG. Several alternatives were under discussion, ANG, aNIM/mPNG, “PNG in GIF” and its subset “RGBA in GIF”.

Comparison to Graphics Interchange Format (GIF)

  • On small images, GIF can achieve greater compression than PNG (see the section on filesize, below).
  • On most images, except for the above cases, GIF will be bigger than indexed PNG.
  • PNG gives a much wider range of transparency options than GIF, including alpha channel transparency.
  • Whereas GIF is limited to 8-bit indexed color
    Indexed color
    In computing, indexed color is a technique to manage digital images' colors in a limited fashion, in order to save computer memory and file storage, while speeding up display refresh and file transfers...

    , PNG gives a much wider range of color depths, including 24-bit (8 bits per channel) and 48-bit (16 bits per channel) truecolor, allowing for greater color precision, smoother fades, etc. When an alpha channel is added, up to 64 bits per pixel (before compression) are possible.
  • GIF intrinsically supports animated images. PNG supports animation only via unofficial extensions (see the section on animation, above).
  • PNG images are less widely supported (e.g. older web browsers and office software).
  • PNG images render more quickly on the screen than GIF

Comparison to JPEG

JPEG
JPEG
In computing, JPEG . The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality. JPEG typically achieves 10:1 compression with little perceptible loss in image quality....

 (Joint Photographic Experts Group) format can produce a smaller file than PNG for photographic
Photography
Photography is the art, science and practice of creating durable images by recording light or other electromagnetic radiation, either electronically by means of an image sensor or chemically by means of a light-sensitive material such as photographic film...

 (and photo-like) images, since JPEG uses a lossy encoding method specifically designed for photographic image data, which is typically dominated by soft, low-contrast transitions, and an amount of noise or similar irregular structures. Using PNG instead of a high-quality JPEG for such images would result in a large increase in filesize with negligible
Transparency (data compression)
In data compression or psychoacoustics, transparency is the ideal result of lossy data compression. If a lossy compressed result is perceptually indistinguishable from the uncompressed input, then the compression can be declared to be transparent...

 gain in quality. By contrast, when storing images that contain text, line art, or graphics – images with sharp transitions and large areas of solid color – the PNG format can compress image data more than JPEG can, and without the noticeable visual artifacts which JPEG produces around high-contrast areas. Where an image contains both sharp transitions and photographic parts a choice must be made between the two effects. Note that JPEG does not support transparency.

Also, JPEG suffers from generation loss
Generation loss
Generation loss refers to the loss of quality between subsequent copies or transcodes of data. Anything that reduces the quality of the representation when copying, and would cause further reduction in quality on making a copy of the copy, can be considered a form of generation loss...

 (repeatedly encoding and decoding an image with JPEG will degrade its quality), whereas lossless formats such as PNG do not. Since PNG is extremely inefficient in compressing photographs, sometimes a lossless compression format designed for photographic images – such as lossless JPEG 2000, or Adobe DNG (Digital negative) – is used for storing photographs which might require further editing. When the photograph is finally ready to be distributed, it can then be saved as a JPEG: a single pass of high-quality JPEG encoding will not noticeably degrade a photographic image. Furthermore, PNG does not provide a standard means of embedding Exif
Exchangeable image file format
Exchangeable image file format is a standard that specifies the formats for images, sound, and ancillary tags used by digital cameras , scanners and other systems handling image and sound files recorded by digital cameras...

 image data from sources such as digital cameras, which makes it problematic for use amongst photographers, especially professionals. TIFF, JPEG 2000, and DNG do support such meta data.

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 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 to JPEG-LS

JPEG-LS
JPEG-LS
Lossless JPEG refers to a 1993 addition to JPEG standard by the Joint Photographic Experts Group to enable lossless compression. However, it might be used as an umbrella term to refer to all lossless compression schemes developed by the Joint Photographic Expert group...

 is a "near-lossless" image format by the Joint Photographic Experts Group
Joint Photographic Experts Group
The Joint Photographic Experts Group is the joint committee between ISO/IEC JTC1 and ITU-T that created the JPEG, JPEG 2000, and JPEG XR standards. It is one of two sub-groups of ISO/IEC Joint Technical Committee 1, Subcommittee 29, Working Group 1 - titled as Coding of still pictures...

, though far less widely known and supported than the other lossy JPEG format discussed above. It is directly comparable with PNG, and has a standard set of test images. On the Waterloo Repertoire ColorSet, a standard set of test images (unrelated to the JPEG-LS conformance test set), JPEG-LS generally performs better than PNG, by 10–15%, but on some images PNG performs substantially better, on the order of 50–75%. Thus, if both of these formats are options and file size is an important criterion, they should both be considered, depending on the image.

Comparison to TIFF

Tagged Image File Format
Tagged Image File Format
TIFF is a file format for storing images, popular among graphic artists, the publishing industry, and both amateur and professional photographers in general. As of 2009, it is under the control of Adobe Systems...

 (TIFF) is a format that incorporates an extremely wide range of options. While this makes TIFF useful as a generic format for interchange between professional image editing applications, it makes adding support for it to applications a much bigger task and so it has little support in applications not concerned with image manipulation (such as web browsers). It also means that many applications can read only a subset of TIFF types, creating more potential user confusion.

The most common general-purpose, lossless compression algorithm used with TIFF is Lempel–Ziv–Welch (LZW). This compression technique, also used in GIF, was covered by patents until 2003. There is a TIFF variant that uses the same compression algorithm 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 bilevel images
Binary image
A binary image is a digital image that has only two possible values for each pixel. Typically the two colors used for a binary image are black and white though any two colors can be used. The color used for the object in the image is the foreground color while the rest of the image is the...

 (e.g., faxes or black-and-white text) better than PNG's compression algorithm.

Bitmap graphics editor support for PNG

Popular graphics programs which support the PNG format include Adobe Photoshop
Adobe Photoshop
Adobe Photoshop is a graphics editing program developed and published by Adobe Systems Incorporated.Adobe's 2003 "Creative Suite" rebranding led to Adobe Photoshop 8's renaming to Adobe Photoshop CS. Thus, Adobe Photoshop CS5 is the 12th major release of Adobe Photoshop...

, Corel
Corel
Corel Corporation from the abbreviation is a computer software company headquartered in Ottawa, Ontario, that specializes in graphics processing, similar to Adobe Systems...

's Photo-Paint
Corel PHOTO-PAINT
Corel PHOTO-PAINT is a raster graphics editor developed and marketed by Corel since 1992. Corel currently markets the software for Windows operating systems, previously having marketed versions for Linux and Mac OS...

 and Paint Shop Pro
Corel Paint Shop Pro
Paint Shop Pro is a raster graphics editor and, later in the series, a vector graphics editor for computers running the Microsoft Windows operating system that was originally published by Minneapolis-based Jasc Software. In October 2004, Corel Corporation purchased Jasc Software and the...

, the GIMP
GIMP
GIMP is a free software raster graphics editor. It is primarily employed as an image retouching and editing tool and is freely available in versions tailored for most popular operating systems including Microsoft Windows, Apple Mac OS X, and Linux.In addition to detailed image retouching and...

, GraphicConverter
GraphicConverter
GraphicConverter is computer software that displays and edits computer graphics files. It also converts files between different formats. For example, one can convert a GIF file to a JPEG file....

, Helicon Filter
Helicon Filter
Helicon Filter, also referred to as Helicon, Filter, or as HF, is a proprietary commercial and shareware photo editing software program for Microsoft Windows, similar to such programs as Adobe Photoshop and GIMP, developed and published by Helicon Soft Ltd...

, Inkscape
Inkscape
Inkscape is a free software vector graphics editor, licensed under the GNU General Public License. Its goal is to implement full support for the Scalable Vector Graphics 1.1 standard....

, IrfanView
IrfanView
IrfanView is a freeware/shareware image viewer for Microsoft Windows that can view, edit, and convert image files and play video/audio files. It is noted for its small size, speed, ease of use, and ability to handle a wide variety of graphic file formats, and has some image creation and painting...

, Pixel image editor
Pixel image editor
Pixel Image Editor is an Image editor written by the Slovak programmer Pavel Kanzelsberger. It is written with Free Pascal.-Features:...

, Paint.NET
Paint.NET
Paint.NET is a proprietary freeware raster graphics editor program for Microsoft Windows, developed on the .NET Framework. Originally created by Rick Brewster as a Washington State University student project, Paint.NET has evolved from a simple replacement for the Microsoft Paint program, which is...

 and Xara
Xara Xtreme
Xara Photo & Graphic Designer is a 2D vector graphics editor created by the British software company Xara, which was acquired by German company MAGIX AG in 2007, and now operates as a wholly owned subsidiary. It was previously sold under the names Xara Studio, Xara X and Xara Xtreme...

. Some programs bundled with popular operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s which support PNG include Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

's Paint and Apple's iPhoto
IPhoto
iPhoto is a digital photograph manipulation software application developed by Apple Inc. and released with every Macintosh personal computer as part of the iLife suite of digital life management applications...

 and Preview
Preview (software)
Preview is Mac OS X's application for displaying images and Portable Document Format documents. Like Mac OS X itself, it comes from NeXT's OPENSTEP operating system....

, with the GIMP also often being bundled with popular Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 distributions.

Adobe Fireworks (formerly by Macromedia
Macromedia
Macromedia was an American graphics and web development software company headquartered in San Francisco, California that produced such products as Flash and Dreamweaver. Its rival, Adobe Systems, acquired Macromedia on December 3, 2005 and controls the line of Macromedia...

) uses PNG as its native file format, allowing other image editors and preview utilities to view the flattened image. However, Fireworks by default also stores meta data for layers, animation, vector data, text and effects. Such files should not be distributed directly. Fireworks can instead export the image as an optimized PNG without the extra meta data for use on web pages, etc.

Some image processing programs have PNG compression problems, mainly related to lack of full implementation of the PNG compressor library. These include:
  • Microsoft's Paint for Windows XP
  • Microsoft Picture It! Photo Premium 9
  • older versions of Adobe Photoshop.

Adobe's Fireworks is sometimes placed in this category, but its difficulties are less severe than the other entries. The confusion stems from a misunderstanding of the mechanics of its Save format: though PNGs, the intermediate images produced by that option include large, private chunks containing complete layer and vector information, which allows further, lossless editing. Properly saved with the Export option, Fireworks' PNGs are competitive with those produced by other image editors, but are no longer editable as anything but flattened bitmaps. Fireworks is unable to save size-optimized vector-editable PNGs.

Web browser support for PNG

PNG support first appeared in Internet Explorer
Internet Explorer
Windows Internet Explorer is a series of graphical web browsers developed by Microsoft and included as part of the Microsoft Windows line of operating systems, starting in 1995. It was first released as part of the add-on package Plus! for Windows 95 that year...

 4.0b1 and in Netscape
Netscape
Netscape Communications is a US computer services company, best known for Netscape Navigator, its web browser. When it was an independent company, its headquarters were in Mountain View, California...

 4.04.

Despite calls by the Free Software Foundation
Free Software Foundation
The Free Software Foundation is a non-profit corporation founded by Richard Stallman on 4 October 1985 to support the free software movement, a copyleft-based movement which aims to promote the universal freedom to create, distribute and modify computer software...

 and the World Wide Web Consortium
World Wide Web Consortium
The World Wide Web Consortium is the main international standards organization for the World Wide Web .Founded and headed by Tim Berners-Lee, the consortium is made up of member organizations which maintain full-time staff for the purpose of working together in the development of standards for the...

 (W3C), tools such as gif2png, and campaigns such as Burn All GIFs, PNG adoption on websites has been fairly slow due to late and buggy support in Internet Explorer, particularly regarding transparency.

GIF
GIF
The Graphics Interchange Format is a bitmap image format that was introduced by CompuServe in 1987 and has since come into widespread usage on the World Wide Web due to its wide support and portability....

 is found to be in use more than PNG for a few reasons:
  • No support on old browsers (such as Internet Explorer below version 4).
  • No animation, still images only (unlike GIF, though Mozilla's unofficial APNG
    APNG
    The Animated Portable Network Graphics file format is an unofficial extension to the Portable Network Graphics specification. It allows for animated PNG files that work similarly to animated GIF files, while supporting 24-bit images and 8-bit transparency not available for GIFs...

     format is a potential solution).


PNG compatible browsers include: Apple Safari
Safari (web browser)
Safari is a web browser developed by Apple Inc. and included with the Mac OS X and iOS operating systems. First released as a public beta on January 7, 2003 on the company's Mac OS X operating system, it became Apple's default browser beginning with Mac OS X v10.3 "Panther". Safari is also the...

, Google Chrome
Google Chrome
Google Chrome is a web browser developed by Google that uses the WebKit layout engine. It was first released as a beta version for Microsoft Windows on September 2, 2008, and the public stable release was on December 11, 2008. The name is derived from the graphical user interface frame, or...

, Mozilla Firefox
Mozilla Firefox
Mozilla Firefox is a free and open source web browser descended from the Mozilla Application Suite and managed by Mozilla Corporation. , Firefox is the second most widely used browser, with approximately 25% of worldwide usage share of web browsers...

, Opera
Opera (web browser)
Opera is a web browser and Internet suite developed by Opera Software with over 200 million users worldwide. The browser handles common Internet-related tasks such as displaying web sites, sending and receiving e-mail messages, managing contacts, chatting on IRC, downloading files via BitTorrent,...

, Camino
Camino
Camino is a free, open source, GUI-based Web browser based on Mozilla's Gecko layout engine and specifically designed for the Mac OS X operating system...

, Internet Explorer 7
Internet Explorer 7
Windows Internet Explorer 7 is a web browser released by Microsoft in October 2006. Internet Explorer 7 is part of a long line of versions of Internet Explorer and was the first major update to the browser in more than 5 years...

 (still numerous issues), Internet Explorer 8
Internet Explorer 8
Windows Internet Explorer 8 is a web browser developed by Microsoft in the Internet Explorer browser series. The browser was released on March 19, 2009 for Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, and Windows 7. Both 32-bit and 64-bit builds are available...

 (still some issues), Internet Explorer 9
Internet Explorer 9
Windows Internet Explorer 9 is the current version of the Internet Explorer web browser from Microsoft. It was released to the public on March 14, 2011 at 21:00 PDT. Internet Explorer 9 supports several CSS 3 properties, embedded ICC v2 or v4 color profiles support via Windows Color System, and...

 and many others. For the complete comparison, see Comparison of web browsers (Image format support).

However, versions of Internet Explorer (Windows) below 9.0 have numerous problems which prevent it from correctly rendering PNG images.

Operating system support for PNG icons

PNG icons have been supported in most distributions of Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

 since at least 1999, in desktop environments such as GNOME
GNOME
GNOME is a desktop environment and graphical user interface that runs on top of a computer operating system. It is composed entirely of free and open source software...

. In 2006, PNG icons were introduced into Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

, in Windows Vista
Windows Vista
Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...

. PNG icons are supported in AROS
Aros
Aros may refer to:*Aros , a river in J. R. R. Tolkien's Middle-earth legendarium*AROS Research Operating System, a free software implementation of AmigaOS* Aros, the original Viking name of Aarhus, the second largest city in Denmark...

, Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

 and MorphOS
MorphOS
MorphOS is an Amiga-compatible computer operating system. It is a mixed proprietary and open source OS produced for the Pegasos PowerPC processor based computer, PowerUP accelerator equipped Amiga computers, and a series of Freescale development boards that use the Genesi firmware, including the...

 as well.

File size and optimization software

PNG file size can vary significantly depending on how it is encoded and compressed; this is discussed and a number of tips are given in PNG: The Definitive Guide.

Compared to GIF

Compared to GIF files, a PNG file with the same information (256 colors, no ancillary chunks/metadata), compressed by a good compressor will often be smaller than GIF, though lack of agreed data sets make any controlled comparisons subjective. Depending on the file and the compressor, PNG may range from somewhat smaller (10%) to significantly smaller (50%) to somewhat larger (5%), but is rarely significantly larger for large images. This is attributed to the performance of PNG's DEFLATE
DEFLATE
Deflate is a lossless data compression algorithm that uses a combination of the LZ77 algorithm and Huffman coding. It was originally defined by Phil Katz for version 2 of his PKZIP archiving tool and was later specified in RFC 1951....

 compared to GIF's LZW
LZW
Lempel–Ziv–Welch is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch. It was published by Welch in 1984 as an improved implementation of the LZ78 algorithm published by Lempel and Ziv in 1978...

, and because the added precompression layer of PNG's predictive filters take account of the 2-dimensional image structure to further compress files; as filtered data encodes differences between pixels, they will tend to cluster closer to 0, rather than being spread across all possible values, and thus be more easily compressed by DEFLATE.

File size factors

PNG files vary in size due to a number of factors:
color depth: Color depth can range from 1 to 64 bits per pixel.
ancillary chunks: PNG supports metadata—this may be useful for editing, but unnecessary for viewing, as on websites.
interlacing: As each pass of the Adam7 algorithm is separately filtered, this can increase file size.
filter: As a precompression stage, each line is filtered by a predictive filter, which can change from line to line. As the ultimate DEFLATE step operates on the whole image's filtered data, one cannot optimize this row-by-row; the choice of filter for each row is thus potentially very variable, though heuristics exist.
compression: With additional computation, DEFLATE compressors can produce smaller files.
There is thus a filesize trade-off between high color depth, maximal metadata (including color space information, together with information that does not affect display), interlacing, and speed of compression, which all yield large files, with lower color depth, fewer or no ancillary chunks, no interlacing, and tuned but computationally intensive filtering and compression. For different purposes one will choose different trade-offs: a maximal file may be best for archiving and editing, while a stripped down file may be best for use on a website, and similarly fast but poor compression is preferred when repeatedly editing and saving a file, while slow but high compression is preferred when a file is stable: when archiving or posting.
Interlacing is a trade-off: it dramatically speeds up early rendering of large files (improves latency), but may increase file size (decrease throughput) for little gain, particularly for small files.

Image editing software

Image editing software varies in its treatment of PNGs.

Because GIF is de facto limited to 256 colors (GIF87a Standard), image editors must automatically reduce the color depth when saving an image in GIF format. Often, when people save the same truecolor image as PNG and GIF, they see that the GIF is smaller, and do not realize that this is due to the color depth reduction, and that it is possible to create a 256-color PNG that has identical quality to the GIF with a smaller file size. Further, some tools may automatically create PNG files as 24-bit, even if the source image is 8-bit, bloating the file.
This leads to the misconception that PNG files are larger than equivalent GIF files.

Some versions of Adobe Photoshop
Adobe Photoshop
Adobe Photoshop is a graphics editing program developed and published by Adobe Systems Incorporated.Adobe's 2003 "Creative Suite" rebranding led to Adobe Photoshop 8's renaming to Adobe Photoshop CS. Thus, Adobe Photoshop CS5 is the 12th major release of Adobe Photoshop...

, CorelDRAW
CorelDRAW
CorelDRAW is a vector graphics editor developed and marketed by Corel Corporation of Ottawa, Canada. It is also the name of Corel's Graphics Suite...

 and MS Paint provide poor PNG compression effort, further fueling the idea that PNG is larger than GIF. Many graphics programs (such as Apple's Preview
Preview (software)
Preview is Mac OS X's application for displaying images and Portable Document Format documents. Like Mac OS X itself, it comes from NeXT's OPENSTEP operating system....

 software) save PNGs with large amounts of metadata
Metadata
The term metadata is an ambiguous term which is used for two fundamentally different concepts . Although the expression "data about data" is often used, it does not apply to both in the same way. Structural metadata, the design and specification of data structures, cannot be about data, because at...

 and color-correction data that are generally unnecessary for Web
World Wide Web
The World Wide Web is a system of interlinked hypertext documents accessed via the Internet...

 viewing. Unoptimized PNG files from Adobe Fireworks are also notorious for this since they contain options to make the image editable in supported editors. Also CorelDRAW (at least version 11) sometimes produces PNGs which cannot be opened by Internet Explorer (versions 6–8).

Adobe Photoshop
Adobe Photoshop
Adobe Photoshop is a graphics editing program developed and published by Adobe Systems Incorporated.Adobe's 2003 "Creative Suite" rebranding led to Adobe Photoshop 8's renaming to Adobe Photoshop CS. Thus, Adobe Photoshop CS5 is the 12th major release of Adobe Photoshop...

's performance on PNG files has improved in the CS Suite when using the Save For Web feature (which also allows explicit PNG/8 use).

Optimizing tools

Various tools are available for optimizing PNG files; they do this by:
  • (optionally) removing ancillary chunks,
  • reducing color depth, either:
    • use a palette (instead of RGB) if the image has 256 or fewer colors,
    • use a smaller palette, if the image has 2, 4, or 16 colors, or
    • (optionally) lossily discard some of the data in the original image,
  • optimizing line-by-line filter choice, and
  • optimizing DEFLATE compression.


As some tools are PNG-specific, while others only optimize DEFLATE, in general one must use a combination of 2 tools in sequence for optimal compression: one which optimizes filters (and removes ancillary chunks), and one which optimizes DEFLATE. Most commonly, OptiPNG is used for the first (non-DEFLATE) step, and either of AdvanceCOMP or PNGOUT is used for the DEFLATE step.

Ancillary chunk removal

For removing ancillary chunks, pngcrush
Pngcrush
pngcrush is a free, open source command-line utility for optimizing PNG image files. It reduces the size of the file losslessly — that is, the resulting "crushed" image will have the same quality as the source image....

 and PNGOUT
PNGOUT
PNGOUT is a freeware command line optimizer for PNG images written by Ken Silverman. The compression is lossless, meaning that the resulting image will have exactly the same appearance as the source image...

 have the ability to remove all color correction data from PNG files (gamma, white balance, ICC color profile, standard RGB color profile). This often results in much smaller file sizes. The following command line options achieve this with pngcrush:

pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB InputFile.png OutputFile.png

Filter optimization

For optimizing filters, OptiPNG and pngcrush
Pngcrush
pngcrush is a free, open source command-line utility for optimizing PNG image files. It reduces the size of the file losslessly — that is, the resulting "crushed" image will have the same quality as the source image....

 are both open source software optimizers that run from a Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 command line or a Windows Command Prompt, and effectively reduce the size of PNG files. OptiPNG was based on pngcrush and effectively supersedes it, by iterating over a wider range of compression parameters and performing trials in memory for faster execution, as well as performing automatic bit depth, color type and color palette reduction where possible.

DEFLATE optimization

AdvanceCOMP
AdvanceCOMP
AdvanceCOMP is a set of cross-platform command line data compression tools. The utilities allow modifying an already-compressed file, with the intent of reducing the file-size by optimising the compressed representation...

 advdef and Ken Silverman
Ken Silverman
Ken Silverman is a game programmer, best known for writing the Build engine used in Duke Nukem 3D, Shadow Warrior, Blood, and more than a dozen other games in the mid- to late-1990s...

's PNGOUT
PNGOUT
PNGOUT is a freeware command line optimizer for PNG images written by Ken Silverman. The compression is lossless, meaning that the resulting image will have exactly the same appearance as the source image...

 and Glenn Randers-Pehrson's pngcrush
Pngcrush
pngcrush is a free, open source command-line utility for optimizing PNG image files. It reduces the size of the file losslessly — that is, the resulting "crushed" image will have the same quality as the source image....

 and Image::Pngslimmer
Image-Pngslimmer
In computer programming, Image::Pngslimmer is a Perl module of functions to reduce the size of PNG computer graphics. The module offers several basic functions, including:...

 employ DEFLATE
DEFLATE
Deflate is a lossless data compression algorithm that uses a combination of the LZ77 algorithm and Huffman coding. It was originally defined by Phil Katz for version 2 of his PKZIP archiving tool and was later specified in RFC 1951....

 compression algorithms that are more exhaustive and produce smaller files than the reference implementation, zlib
Zlib
zlib is a software library used for data compression. zlib was written by Jean-Loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compression program. Zlib is also a crucial component of many software platforms including Linux, Mac OS X,...

, that is used by the other compressors.

Wrapper tools

Wrapper tools that simplify this workflow include: ImageOptim, a GUI front-end for Mac OS X; Kashmir Web Optimizer- GUI front-end for Windows; imgopt, a command-line shell script that also losslessly optimizes JPEG images; and Smush.it, an image-optimizing web service.

The littleutils are another open-source package, containing a wrapper script called opt-png that uses pngcrush
Pngcrush
pngcrush is a free, open source command-line utility for optimizing PNG image files. It reduces the size of the file losslessly — that is, the resulting "crushed" image will have the same quality as the source image....

 and a variant of pngrewrite to reduce bit-depth when possible. Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

 scripts might wish to employ Image-Pngslimmer
Image-Pngslimmer
In computer programming, Image::Pngslimmer is a Perl module of functions to reduce the size of PNG computer graphics. The module offers several basic functions, including:...

 which allows some dynamic optimization.

The current version of IrfanView
IrfanView
IrfanView is a freeware/shareware image viewer for Microsoft Windows that can view, edit, and convert image files and play video/audio files. It is noted for its small size, speed, ease of use, and ability to handle a wide variety of graphic file formats, and has some image creation and painting...

 can use PNGOUT as an external plug-in, obviating the need for a separate compressor.

Icon optimization

Since icons
Computer icon
A computer icon is a pictogram displayed on a computer screen and used to navigate a computer system or mobile device. The icon itself is a small picture or symbol serving as a quick, intuitive representation of a software tool, function or a data file accessible on the system. It functions as an...

 intended for Windows Vista and later versions may contain PNG subimages, the optimizations can be applied to them as well. At least one icon editor, Pixelformer, is able to perform a special optimization pass while saving ICO
ICO (icon image file format)
The ICO file format is an image file format for computer icons in Microsoft Windows. ICO files contain one or more small images at multiple sizes and color depths, such that they may be scaled appropriately...

 files, thereby reducing their sizes.

See also

  • Comparison of graphics file formats
    Comparison of graphics file formats
    -General:Ownership of the format and related information.-Technical details:...

  • Computer graphics
    Computer graphics
    Computer graphics are graphics created using computers and, more generally, the representation and manipulation of image data by a computer with help from specialized software and hardware....

    , including:
    • Comparison of layout engines (graphics)
      Comparison of layout engines (graphics)
      The following tables compare graphics compatibility and support for a number of layout engines. Please see the individual products' articles for further information. This article is not all-inclusive or necessarily up-to-date...

  • Image editing
    Image editing
    Image editing encompasses the processes of altering images, whether they be digital photographs, traditional analog photographs, or illustrations. Traditional analog image editing is known as photo retouching, using tools such as an airbrush to modify photographs, or editing illustrations with any...

  • Image file formats
    Image file formats
    Image file formats are standardized means of organizing and storing digital images. Image files are composed of either pixels, vector data, or a combination of the two. Whatever the format, the files are rasterized to pixels when displayed on most graphic displays...

  • libpng
    Libpng
    libpng is the official Portable Network Graphics reference library . It is a platform-independent library that contains C functions for handling PNG images...

  • Related graphics file formats
    • APNG
      APNG
      The Animated Portable Network Graphics file format is an unofficial extension to the Portable Network Graphics specification. It allows for animated PNG files that work similarly to animated GIF files, while supporting 24-bit images and 8-bit transparency not available for GIFs...

       Animated PNG
    • JPEG Network Graphics (JNG)
    • Multiple-image Network Graphics (MNG)
  • Similar file formats
    • Graphics Interchange Format (GIF)
    • X PixMap for portable icons
  • .svg

libpng.org


W3C


Others

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK