Portable Network Graphics
   HOME

TheInfoList



OR:

Portable Network Graphics (PNG, officially pronounced , colloquially pronounced ) is a raster-graphics file format that supports
lossless data compression Lossless compression is a class of data compression that allows the original data to be perfectly reconstructed from the compressed data with no loss of information. Lossless compression is possible because most real-world data exhibits Redundanc ...
. PNG was developed as an improved, non-patented replacement for
Graphics Interchange Format The Graphics Interchange Format (GIF; or , ) is a bitmap image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released on June 15, 1987. The format can ...
(GIF). PNG supports palette-based images (with palettes of 24-bit
RGB The RGB color model is an additive color model in which the red, green, and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three ...
or 32-bit
RGBA RGBA stands for red green blue alpha. While it is sometimes described as a color space, it is actually a three-channel RGB color model supplemented with a fourth ''alpha channel''. Alpha indicates how opaque each pixel is and allows an image to ...
colors),
grayscale In digital photography, computer-generated imagery, and colorimetry, a greyscale (more common in Commonwealth English) or grayscale (more common in American English) image is one in which the value of each pixel is a single sample (signal), s ...
images (with or without an
alpha channel In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate pass ...
for transparency), and full-color non-palette-based RGB or RGBA images. The PNG working group designed the format for transferring images on the
Internet The Internet (or internet) is the Global network, global system of interconnected computer networks that uses the Internet protocol suite (TCP/IP) to communicate between networks and devices. It is a internetworking, network of networks ...
, not for professional-quality print graphics; therefore, non-RGB
color space A color space is a specific organization of colors. In combination with color profiling supported by various physical devices, it supports reproducible representations of colorwhether such representation entails an analog or a digital represe ...
s such as
CMYK The CMYK color model (also known as process color, or four color) is a subtractive color model, based on the CMY color model, used in color printing, and is also used to describe the printing process itself. The abbreviation ''CMYK'' refers ...
are not supported. A PNG file contains a single image in an extensible structure of ''chunks'', encoding the basic
pixel In digital imaging, a pixel (abbreviated px), pel, or picture element is the smallest addressable element in a Raster graphics, raster image, or the smallest addressable element in a dot matrix display device. In most digital display devices, p ...
s and other information such as textual comments and integrity checks documented in RFC 2083. PNG files have the ".png"
file extension File or filing may refer to: Mechanical tools and processes * File (tool), a tool used to remove fine amounts of material from a workpiece. ** Filing (metalworking), a material removal process in manufacturing ** Nail file, a tool used to gen ...
and the "image/png"
MIME A mime artist, or simply mime (from Greek language, Greek , , "imitator, actor"), is a person who uses ''mime'' (also called ''pantomime'' outside of Britain), the acting out of a story through body motions without the use of speech, as a the ...
media type. PNG was published as an informational RFC 2083 in March 1997 and as an
ISO/IEC ISO/IEC JTC 1, entitled "Information technology", is a joint technical committee (JTC) of the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC). Its purpose is to develop, maintain and ...
15948 standard in 2004.


History and development

The motivation for creating the PNG format was the announcement on 28 December 1994 that implementations of the
Graphics Interchange Format The Graphics Interchange Format (GIF; or , ) is a bitmap image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released on June 15, 1987. The format can ...
(GIF) format would have to pay royalties to
Unisys Unisys Corporation is a global technology solutions company founded in 1986 and headquartered in Blue Bell, Pennsylvania. The company provides cloud, AI, digital workplace, logistics, and enterprise computing services. History Founding Unis ...
due to their
patent A patent is a type of intellectual property that gives its owner the legal right to exclude others from making, using, or selling an invention for a limited period of time in exchange for publishing an sufficiency of disclosure, enabling discl ...
of the
Lempel–Ziv–Welch Lempel–Ziv–Welch (LZW) 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 Lem ...
(LZW)
data compression In information theory, data compression, source coding, or bit-rate reduction is the process of encoding information using fewer bits than the original representation. Any particular compression is either lossy or lossless. Lossless compressi ...
algorithm used in GIF. This led to a flurry of criticism from
Usenet Usenet (), a portmanteau of User's Network, is a worldwide distributed discussion system available on computers. It was developed from the general-purpose UUCP, Unix-to-Unix Copy (UUCP) dial-up network architecture. Tom Truscott and Jim Elli ...
users. One of them was Thomas Boutell, who on 4 January 1995 posted a precursory discussion thread on the
Usenet newsgroup A Usenet newsgroup is a repository usually within the Usenet system for messages posted from users in different locations using the Internet. They are not only discussion groups or conversations, but also a repository to publish articles, start ...
"comp.graphics" in which he devised a plan for a free alternative to GIF. Other users in that thread put forth many propositions that would later be part of the final file format. Oliver Fromme, author of the popular
JPEG JPEG ( , short for Joint Photographic Experts Group and sometimes retroactively referred to as JPEG 1) is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degr ...
viewer QPEG, proposed the PING name, eventually becoming PNG, a
recursive acronym A recursive acronym is an acronym that refers to itself, and appears most frequently in computer programming. The term was first used in print in 1979 in Douglas Hofstadter's book '' Gödel, Escher, Bach: An Eternal Golden Braid'', in which Hofs ...
meaning ''PING is not GIF'', and also the .png extension. Other suggestions later implemented included the deflate compression algorithm and
24-bit color Color depth, also known as bit depth, is either the number of bits used to indicate the color of a single pixel, or the number of bits used for each color component of a single pixel. When referring to a pixel, the concept can be defined as bit ...
support, the lack of the latter in GIF also motivating the team to create their file format. The group would become known as the PNG Development Group, and as the discussion rapidly expanded, it later used a mailing list associated with a
CompuServe CompuServe, Inc. (CompuServe Information Service, Inc., also known by its initialism CIS or later CSi) was an American Internet company that provided the first major commercial online service provider, online service. It opened in 1969 as a times ...
forum. The full specification of PNG was released under the approval of
W3C The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working together in ...
on 1 October 1996, and later as RFC 2083 on 15 January 1997. The specification was revised on 31 December 1998 as version 1.1, which addressed technical problems for
gamma Gamma (; uppercase , lowercase ; ) is the third letter of the Greek alphabet. In the system of Greek numerals it has a value of 3. In Ancient Greek, the letter gamma represented a voiced velar stop . In Modern Greek, this letter normally repr ...
and
color correction Color correction is a process used in stage lighting, photography, television, cinematography, and other disciplines, which uses color gels, or filters, to alter the overall color of the light. Typically the light color is measured on a scale k ...
. Version 1.2, released on 11 August 1999, added the iTXt chunk as the specification's only change, and a reformatted version of 1.2 was released as a second edition of the W3C standard on 10 November 2003, and as an International Standard
ISO/IEC 15948:2004
on 3 March 2004. Although GIF allows for
animation Animation is a filmmaking technique whereby still images are manipulated to create moving images. In traditional animation, images are drawn or painted by hand on transparent celluloid sheets to be photographed and exhibited on film. Animati ...
, it was initially decided that PNG should be a single-image format. In 2001, the developers of PNG published the
Multiple-image Network Graphics Multiple-image Network Graphics (MNG) is a graphics file format published in 2001 for animated images. Its specification is publicly documented and there are free software reference implementations available. MNG is closely related to the PNG ...
(MNG) format, with support for animation. MNG achieved moderate application support, but not enough among mainstream web browsers and no usage among web site designers or publishers. In 2008, certain
Mozilla Mozilla is a free software community founded in 1998 by members of Netscape. The Mozilla community uses, develops, publishes and supports Mozilla products, thereby promoting free software and open standards. The community is supported institution ...
developers published the Animated Portable Network Graphics (APNG) format with similar goals. APNG is a format that is natively supported by
Gecko Geckos are small, mostly carnivorous lizards that have a wide distribution, found on every continent except Antarctica. Belonging to the infraorder Gekkota, geckos are found in warm climates. They range from . Geckos are unique among lizards ...
- and Presto-based web browsers and is also commonly used for thumbnails on Sony's
PlayStation Portable The PlayStation Portable (PSP) is a handheld game console developed and marketed by Sony Interactive Entertainment, Sony Computer Entertainment. It was first released in Japan on December 12, 2004, in North America on March 24, 2005, and in PA ...
system (using the normal PNG file extension). In 2017, Chromium based browsers adopted APNG support. In January 2020,
Microsoft Edge Microsoft Edge is a Proprietary Software, proprietary cross-platform software, cross-platform web browser created by Microsoft and based on the Chromium (web browser), Chromium open-source project, superseding Edge Legacy. In Windows 11, Edge ...
became
Chromium Chromium is a chemical element; it has Symbol (chemistry), symbol Cr and atomic number 24. It is the first element in Group 6 element, group 6. It is a steely-grey, Luster (mineralogy), lustrous, hard, and brittle transition metal. Chromium ...
based, thus inheriting support for APNG. With this all major browsers now support APNG.


PNG Working Group

The original PNG specification was authored by an ad hoc group of
computer graphics Computer graphics deals with generating images and art with the aid of computers. Computer graphics is a core technology in digital photography, film, video games, digital art, cell phone and computer displays, and many specialized applications. ...
experts and enthusiasts. Discussions and decisions about the format were conducted by email. The original authors listed on RFC 2083 are: *Editor: Thomas Boutell *Contributing Editor: Tom Lane *Authors (in alphabetical order by last name):
Mark Adler Mark Adler (born 1959) is an American software engineer. He is best known for his work in the field of data compression as the author of the Adler-32 checksum function, and a co-author, together with Jean-loup Gailly, of the zlib compression lib ...
, Thomas Boutell, Christian Brunschen, Adam M. Costello,
Lee Daniel Crocker Lee Daniel Crocker (born July 3, 1963) is an American computer programmer. He is best known for rewriting the software upon which Wikipedia runs, to address scalability problems. This software, originally known as "Phase III", went live in Jul ...
, Andreas Dilger, Oliver Fromme, Jean-loup Gailly, 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


File format


File header

A PNG file starts with an eight-
byte The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable un ...
signature A signature (; from , "to sign") is a depiction of someone's name, nickname, or even a simple "X" or other mark that a person writes on documents as a proof of identity and intent. Signatures are often, but not always, Handwriting, handwritt ...
(refer to hex editor image on the right):


"Chunks" within the file

After the header, comes 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 storage layer structure, similar in concept to a
container format A container format (informally, sometimes called a wrapper) or metafile is a file format that allows multiple data streams to be embedded into a single file, usually along with metadata for identifying and further detailing those streams. Nota ...
or to
Amiga Amiga is a family of personal computers produced by Commodore International, Commodore from 1985 until the company's bankruptcy in 1994, with production by others afterward. The original model is one of a number of mid-1980s computers with 16-b ...
s
IFF In logic and related fields such as mathematics and philosophy, "if and only if" (often shortened as "iff") is paraphrased by the biconditional, a logical connective between statements. The biconditional is true in two cases, where either both ...
, is designed to allow the PNG format to be extended while maintaining compatibility with older versions—it provides
forward compatibility Forward compatibility or upward compatibility is a design characteristic that allows a system to accept input intended for a later version of itself. The concept can be applied to entire systems, electrical interfaces, telecommunication signal ...
, and this same file structure (with different signature and chunks) is used in the associated MNG, JNG, and APNG formats. A chunk consists of four parts: length (4 bytes,
big-endian '' Jonathan_Swift.html" ;"title="Gulliver's Travels'' by Jonathan Swift">Gulliver's Travels'' by Jonathan Swift, the novel from which the term was coined In computing, endianness is the order in which bytes within a word (data type), word of d ...
), chunk type/name (4 bytes), chunk data (length bytes) and CRC (cyclic redundancy code/checksum; 4 bytes). The CRC is a network-byte-order CRC-32 computed over the chunk type and chunk data, but not the length. Chunk types are given a four-letter case sensitive ASCII type/name; compare
FourCC A FourCC ("four-character code") is a sequence of four bytes (typically ASCII) used to uniquely identify data formats. It originated from the OSType or ResType metadata system used in classic Mac OS and was adopted for the Amiga/Electronic Arts ...
. The case of the different letters in the name (bit 5 of the numeric value of the character) is a
bit field A bit field is a data structure that maps to one or more adjacent bits which have been allocated for specific purposes, so that any single bit or group of bits within the structure can be set or inspected. A bit field is most commonly used to repre ...
that provides the
decoder Decoder may refer to: Technology * Audio decoder converts digital audio to analog form * Binary decoder, digital circuits such as 1-of-N and seven-segment decoders * Decompress (compression decoder), converts compressed data (e.g., audio/video/i ...
with some information on the nature of chunks it does not recognize. The case of the first letter indicates whether 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 whether the chunk is "public" (either in the specification or the registry of special-purpose public chunks) or "private" (not standardized). 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 unrecognized chunk. The case of the fourth letter indicates whether the 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 critical chunks to read and render a PNG file. * IHDR must be the first chunk; it contains (in this order) the image's **width (4 bytes) **height (4 bytes) **bit depth (1 byte, values 1, 2, 4, 8, or 16) **color type (1 byte, values 0, 2, 3, 4, or 6) **compression method (1 byte, value 0) **filter method (1 byte, value 0) **interlace method (1 byte, values 0 "no interlace" or 1 " Adam7 interlace") (13 data bytes total). As stated in the
World Wide Web Consortium The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working together in ...
, bit depth is defined as "the number of bits per sample or per palette index (not per pixel)". * PLTE contains the palette: a list of colors. * IDAT contains the image, which may be split among multiple IDAT chunks. Such splitting slightly increases the file size, but makes it possible to generate a PNG in a streaming manner. The IDAT chunk contains the actual image data, which is the output stream of the compression algorithm. * IEND marks the image end; the data field of the IEND chunk has 0 bytes/is empty. The PLTE chunk is essential for color type 3 (indexed color). It is optional for color types two and six (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 (; uppercase , lowercase ; ) is the third letter of the Greek alphabet. In the system of Greek numerals it has a value of 3. In Ancient Greek, the letter gamma represented a voiced velar stop . In Modern Greek, this letter normally repr ...
values, background color, and textual
metadata Metadata (or metainformation) is "data that provides information about other data", but not the content of the data itself, such as the text of a message or the image itself. There are many distinct types of metadata, including: * Descriptive ...
information. PNG also supports
color management Color management is the process of ensuring consistent and accurate colors across various devices, such as monitors, printers, and cameras. It involves the use of color profiles, which are standardized descriptions of how colors should be disp ...
through the inclusion of ICC color 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 is an objective specification of the quality of a color regardless of its luminance. Chromaticity consists of two independent parameters, often specified as '' hue'' (''h'') and ''colorfulness'' (''s''), where the latter is alte ...
coordinates of the display
primaries Primary elections or primaries are elections held to determine which candidates will run in an upcoming general election. In a partisan primary, a political party selects a candidate. Depending on the state and/or party, there may be an "open pri ...
and
white point A white point (often referred to as reference white or target white in technical documents) is a set of tristimulus values or chromaticity coordinates that serve to define the color "white" in image capture, encoding, or reproduction. Depending o ...
. * cICP specifies the color space, transfer function and matrix coefficients as defined in ITU-T H.273. It is intended for use with HDR imagery without requiring a color profile. * dSIG is for storing digital signatures. * eXIf stores
Exif Exchangeable image file format (officially Exif, according to JEIDA/JEITA/CIPA specifications) is a standard that specifies formats for images, sound, and ancillary tags used by digital cameras (including smartphones), scanners and other system ...
metadata. * gAMA specifies
gamma Gamma (; uppercase , lowercase ; ) is the third letter of the Greek alphabet. In the system of Greek numerals it has a value of 3. In Ancient Greek, the letter gamma represented a voiced velar stop . In Modern Greek, this letter normally repr ...
. The gAMA chunk contains only 4 bytes, and its value represents the gamma value multiplied by 100,000; for example, the gamma value 1/3.4 calculates to 29411.7647059 ((1/3.4)*(100,000)) and is converted to an integer (29412) for storage. * hIST can store the histogram, or total amount of each color in the image. * iCCP is an ICC color profile. * iTXt contains a keyword and
UTF-8 UTF-8 is a character encoding standard used for electronic communication. Defined by the Unicode Standard, the name is derived from ''Unicode Transformation Format 8-bit''. Almost every webpage is transmitted as UTF-8. UTF-8 supports all 1,112,0 ...
text, with encodings for possible compression and translations marked with language tag. The
Extensible Metadata Platform The Extensible Metadata Platform (XMP) is an ISO standard, originally created by Adobe Systems Inc., for the creation, processing and interchange of standardized and custom metadata for digital documents and data sets. XMP standardizes a data ...
(XMP) uses this chunk with a keyword 'XML:com.adobe.xmp' * pHYs holds the intended pixel size (or pixel aspect ratio); the pHYs contains "Pixels per unit, X axis" (4 bytes), "Pixels per unit, Y axis" (4 bytes), and "Unit specifier" (1 byte) for a total of 9 bytes. * sBIT (significant bits) indicates the color-accuracy of the source data; this chunk contains a total of between 1 and 5 bytes, depending on the color type. * sPLT suggests a palette to use if the full range of colors is unavailable. * sRGB indicates that the standard sRGB color space is used; the sRGB chunk contains only 1 byte, which is used for "rendering intent" (4 values—0, 1, 2, and 3—are defined for rendering intent). * sTER stereo-image indicator chunk for
stereoscopic Stereoscopy, also called stereoscopics or stereo imaging, is a technique for creating or enhancing the illusion of depth in an image by means of stereopsis for binocular vision. The word ''stereoscopy'' derives . Any stereoscopic image is ...
images. * tEXt can store text that can be represented in
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 ...
, with one key-value pair for each chunk. The "key" must be between one and 79 characters long. Separator is a null character. The "value" can be any length, including zero up to the maximum permissible chunk size minus the length of the keyword and separator. Neither "key" nor "value" can contain null character. Leading or trailing spaces are also disallowed. * 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 (and a compression method marker) 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.


Pixel format

Pixels in PNG images are numbers that may be either indices of sample data in the palette or the sample data itself. The palette is a separate table contained in the PLTE chunk. Sample data for a single
pixel In digital imaging, a pixel (abbreviated px), pel, or picture element is the smallest addressable element in a Raster graphics, raster image, or the smallest addressable element in a dot matrix display device. In most digital display devices, p ...
consists of a tuple of between one and four numbers. Whether the pixel data represents palette indices or explicit sample values, the numbers are referred to as channels and every number in the image is encoded with an identical format. The permitted formats encode each number as an unsigned integer value using a fixed number of bits, referred to in the PNG specification as the ''bit depth''. Notice that this is not the same as
color depth Color depth, also known as bit depth, is either the number of bits used to indicate the color of a single pixel, or the number of bits used for each color component of a single pixel. When referring to a pixel, the concept can be defined as bit ...
, which is commonly used to refer to the total number of bits in each pixel, not each channel. The permitted bit depths are summarized in the table along with the total number of bits used for each pixel. The number of channels depends on whether the image is grayscale or color and whether it has an
alpha channel In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate pass ...
. PNG allows the following combinations of channels, called the ''color type''. The color type is specified as an 8-bit value however only the low three bits are used and, even then, only the five combinations listed above are permitted. So long as the color type is valid it can be considered as a bit field as summarized in the adjacent table: * bit value 1: the image data stores palette indices. This is only valid in combination with bit value 2; * bit value 2: the image samples contain three channels of data encoding
trichromatic Trichromacy or trichromatism is the possession of three independent channels for conveying color information, derived from the three different types of cone cells in the eye. Organisms with trichromacy are called trichromats. The normal expl ...
color Color (or colour in English in the Commonwealth of Nations, Commonwealth English; American and British English spelling differences#-our, -or, see spelling differences) is the visual perception based on the electromagnetic spectrum. Though co ...
s, otherwise the image samples contain one channel of data encoding
relative luminance Relative luminance Y follows the Luminance, photometric definition of luminance L including spectral weighting for human vision, but while luminance L is a measure of light in units such as cd/m^2, relative luminance Y values are normalized as ...
, * bit value 4: the image samples also contain an alpha channel expressed as a linear measure of the opacity of the pixel. This is not valid in combination with bit value 1. With indexed color images, the palette always stores trichromatic colors at a depth of 8 bits per channel (24 bits per palette entry). Additionally, an optional list of 8-bit alpha values for the palette entries may be included; if not included, or if shorter than the palette, the remaining palette entries are assumed to be opaque. The palette must not have more entries than the image bit depth allows for, but it may have fewer (for example, if an image with 8-bit pixels only uses 90 colors then it does not need palette entries for all 256 colors). The palette must contain entries for all the pixel values present in the image. The standard allows indexed color PNGs to have 1, 2, 4 or 8 bits per pixel; grayscale images with no alpha channel may have 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 true-color and grayscale images either a single pixel value can be declared as transparent or an
alpha channel In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate pass ...
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 is required for compliance with the specification) but only output at 8 bits per channel (the norm for all but the highest end systems). Alpha ''storage'' can be "associated" (" premultiplied") or "unassociated", but PNG standardized on "unassociated" ("non-premultiplied") alpha, which means that imagery is not alpha ''encoded''; the emissions represented in RGB are not the emissions at the pixel level. This means that the over operation will multiply the RGB emissions by the alpha, and cannot represent emission and occlusion properly.


Compression

PNG uses a two-stage compression process: * pre-compression: filtering (prediction) * compression: DEFLATE PNG uses DEFLATE, a non-patented
lossless data compression Lossless compression is a class of data compression that allows the original data to be perfectly reconstructed from the compressed data with no loss of information. Lossless compression is possible because most real-world data exhibits Redundanc ...
algorithm In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
involving a combination of
LZ77 LZ77 and LZ78 are the two lossless data compression algorithms published in papers by Abraham Lempel and Jacob Ziv in 1977 and 1978. They are also known as Lempel-Ziv 1 (LZ1) and Lempel-Ziv 2 (LZ2) respectively. These two algorithms form the basis ...
and
Huffman coding In computer science and information theory, a Huffman code is a particular type of optimal prefix code that is commonly used for lossless data compression. The process of finding or using such a code is Huffman coding, an algorithm developed by ...
. Permissively licensed DEFLATE implementations, such as
zlib zlib ( or "zeta-lib", ) is a software library used for data compression as well as a data format. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compre ...
, are widely available. Compared to formats with
lossy compression In information technology, lossy compression or irreversible compression is the class of data compression methods that uses inexact approximations and partial data discarding to represent the content. These techniques are used to reduce data size ...
such as JPEG, choosing a compression setting higher than average delays processing, but often does not result in a significantly smaller file size.


Filtering

Before DEFLATE is applied, the data is transformed via a prediction method: a single ''filter method'' is used for the entire image, while for each image line, a ''filter type'' is chosen to transform the data to make it more efficiently compressible. The filter type used for a scanline is prepended to the scanline to enable inline decompression. 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. 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''), the pixel above (''B''), and the pixel 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: The Paeth filter is based on an algorithm by Alan W. Paeth. Compare to the version of DPCM used in
lossless JPEG Lossless JPEG is a 1993 addition to JPEG standard by the Joint Photographic Experts Group to enable lossless compression. However, the term may also be used to refer to all lossless compression schemes developed by the group, including JPEG 2000, J ...
, and to the
discrete wavelet transform In numerical analysis and functional analysis Functional analysis is a branch of mathematical analysis, the core of which is formed by the study of vector spaces endowed with some kind of limit-related structure (for example, Inner product sp ...
using 1 × 2, 2 × 1, or (for the Paeth predictor) 2 × 2 windows and
Haar wavelet In mathematics, the Haar wavelet is a 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 repr ...
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 Lee Daniel Crocker (born July 3, 1963) is an American computer programmer. He is best known for rewriting the software upon which Wikipedia runs, to address scalability problems. This software, originally known as "Phase III", went live in Jul ...
, 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 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 f ...
. 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 In mathematics, bicubic interpolation is an extension of cubic spline interpolation (a method of applying cubic interpolation to a data set) for interpolating data points on a two-dimensional regular grid. The interpolated surface (meaning the k ...
are used. However, the 7-pass scheme tends to reduce the data's compressibility more than simpler schemes.


Animation

The core PNG format does not support animation. 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. This means that most web browsers and applications either never supported MNG or dropped support for it. The complexity of MNG led to the proposal of APNG by developers at 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. Today, the APNG format is supported by all major web browsers. APNG is supported in
Firefox Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
3.0 and up,
Pale Moon Pale Moon is a free and open-source web browser licensed under the MPL-2.0 with an emphasis on customization. There are official releases for Microsoft Windows, FreeBSD, macOS, and Linux. Pale Moon originated as a fork of Firefox, but has subs ...
(all versions), and
Safari A safari (; originally ) is an overland journey to observe wildlife, wild animals, especially in East Africa. The so-called big five game, "Big Five" game animals of Africa – lion, African leopard, leopard, rhinoceros, African elephant, elep ...
8.0 and up. Chromium 59.0 added APNG support, followed by Google Chrome.
Opera Opera is a form of History of theatre#European theatre, Western theatre in which music is a fundamental component and dramatic roles are taken by Singing, singers. Such a "work" (the literal translation of the Italian word "opera") is typically ...
supported APNG in versions 10–12.1, but support lapsed in version 15 when it switched to the
Blink Blinking is a bodily function; it is a semi-autonomic rapid closing of the eyelid. A single blink is determined by the forceful closing of the eyelid or inactivation of the levator palpebrae superioris and the activation of the palpebral por ...
rendering engine; support was re-added in Opera 46 (inherited from Chromium 59).
Microsoft Edge Microsoft Edge is a Proprietary Software, proprietary cross-platform software, cross-platform web browser created by Microsoft and based on the Chromium (web browser), Chromium open-source project, superseding Edge Legacy. In Windows 11, Edge ...
has supported APNG since version 79.0, when it switched to a Chromium-based engine. The PNG Group decided in April 2007 not to embrace APNG. Several alternatives were under discussion, including ANG, aNIM/mPNG, "PNG in GIF" and its subset "RGBA in GIF". However, currently only APNG has widespread support. With the development of the Third Edition of the PNG Specification, now maintained by the PNG working group, APNG will finally be incorporated into the specification as an extension.


Examples

Displayed in the fashion of
hex editor A hex editor (or ''binary file editor'' or ''byte editor'') is a computer program that allows for manipulation of the fundamental Binary file, binary data that constitutes a computer file. The name 'hex' comes from 'hexadecimal', a standard numer ...
s, with on the left side byte values shown in hex format, and on the right side their equivalent characters from
ISO-8859-1 ISO/IEC 8859-1:1998, ''Information technology—8-bit computing, 8-bit single-byte coded graphic character (computing), character sets—Part 1: Latin alphabet No. 1'', is part of the ISO/IEC 8859 series of ASCII-based standard character enc ...
with unrecognized and control characters replaced with periods. Additionally the PNG signature and individual chunks are marked with colors. Note they are easy to identify because of their human readable type names (in this example PNG, IHDR, IDAT, and IEND).


Advantages

Reasons to use PNG: *Portability: Transmission is independent of the software and hardware platform. *Completeness: it's possible to represent true color, indexed-color, and grayscale images. *Coding and decoding in series: allows to generate and read data streams in series, that is, the format of the data stream is used for the generation and visualization of images at the moment through serial communication. *Progressive presentation: to be able to transmit data flows that are initially an approximation of the entire image and progressively they improve as the data flow is received. *Soundness to transmission errors: detects the transmission errors of the data stream correctly. *Losslessness: No loss: filtering and compression preserve all information. *Efficiency: any progressive image presentation, compression and filtering seeks efficient decoding and presentation. *Compression: images can be compressed efficiently and consistently. *Easiness: the implementation of the standard is easy. *Interchangeability: any PNG decoder that follows the standards can read all PNG data streams. *Flexibility: allows future extensions and private additions without affecting the previous point. *Freedom of legal restrictions: the algorithms used are free and accessible.


Comparison with other file formats


Graphics Interchange Format (GIF)

* On small images,
GIF The Graphics Interchange Format (GIF; or , ) is a Raster graphics, bitmap Image file formats, image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released ...
can achieve greater compression than PNG (see the section on filesize, below). * On most images, except for the above case, a GIF file has a larger size than an indexed PNG image. * PNG gives a much wider range of transparency options than GIF, including
alpha channel In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate pass ...
transparency. * Whereas GIF is limited to 8-bit
indexed color In computing, indexed color is a technique to manage digital images' colors in a limited fashion, in order to save computer computer data storage, memory and Hard disk drive, file storage, while speeding up display refresh and file transfers. It ...
, 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. * When converting an image from the PNG format to GIF, the image quality may suffer due to
posterization Posterization or posterisation of an image is the conversion of a continuous gradation of tone to several regions of fewer tones, causing abrupt changes from one tone to another. This was originally done with photographic processes to create ...
if the PNG image has more than 256 colors. * GIF intrinsically supports animated images. PNG supports animation only via unofficial extensions (see the section on animation, above). PNG images are less widely supported by older browsers. In particular, IE6 has limited support for PNG.


JPEG

The
JPEG JPEG ( , short for Joint Photographic Experts Group and sometimes retroactively referred to as JPEG 1) is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degr ...
(Joint Photographic Experts Group) format can produce a smaller file than PNG for photographic (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 file size with negligible gain in quality. In comparison, 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. Additionally, PNG is lossless, while JPEG produces visual artifacts around high-contrast areas. (Such artifacts depend on the settings used in the JPG compression; they can be quite noticeable when a low-quality igh-compressionsetting is used.) Where an image contains both sharp transitions and photographic parts, a choice must be made between the two effects. JPEG does not support transparency. JPEG's lossy compression also suffers from
generation loss Generation loss is 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 con ...
, where repeatedly decoding and re-encoding an image to save it again causes a loss of information each time, degrading the image. Because PNG is lossless, it is suitable for storing images to be edited. While PNG is reasonably efficient when compressing photographic images, there are lossless compression formats designed specifically for photographic images, lossless
WebP WebP is a raster graphics file format developed by Google intended as a replacement for JPEG, PNG, and GIF file formats. It supports both lossy and lossless compression, as well as animation and alpha transparency. Google announced the WebP ...
and Adobe DNG (digital negative) for example. However these formats are either not widely supported, or are proprietary. An image can be stored losslessly and converted to JPEG format only for distribution, so that there is no generation loss. While the PNG specification does not explicitly include a standard for embedding
Exif Exchangeable image file format (officially Exif, according to JEIDA/JEITA/CIPA specifications) is a standard that specifies formats for images, sound, and ancillary tags used by digital cameras (including smartphones), scanners and other system ...
image data from sources such as digital cameras, the preferred method for embedding EXIF data in a PNG is to use the non-critical ancillary chunk label eXIf. Early web browsers did not support PNG images; JPEG and GIF were the main image formats. JPEG was commonly used when exporting images containing gradients for web pages, because of GIF's limited color depth. However, JPEG compression causes a gradient to blur slightly. A PNG format reproduces a gradient as accurately as possible for a given bit depth, while keeping the file size small. PNG became the optimal choice for small gradient images as web browser support for the format improved. No images at all are needed to display gradients in modern browsers, as gradients can be created using CSS.


JPEG-LS

JPEG-LS Lossless JPEG is a 1993 addition to JPEG standard by the Joint Photographic Experts Group to enable lossless compression. However, the term may also be used to refer to all lossless compression schemes developed by the group, including JPEG 200 ...
is an image format by the
Joint Photographic Experts Group The Joint Photographic Experts Group (JPEG) is the joint committee between ISO/ IEC JTC 1/ SC 29 and ITU-T Study Group 16 that created and maintains the JPEG, JPEG 2000, JPEG XR, JPEG XT, JPEG XS, JPEG XL, and related digital image standard ...
, 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.


JPEG XL

JPEG XL The JPEG XL Image Coding System is a royalty-free open standard for a image compression, compressed Raster graphics, raster image format. It defines a graphics file format and the abstract device for coding JPEG XL bitstreams. It is developed by t ...
is another, much improved, lossless or lossy format, that is unfortunately supported much less, developed to replace lossless formats like PNG. JPEG XL is more than 50% smaller than JPEG, and that can happen while it's lossless, therefore making it even smaller than PNG. It also supports
high dynamic range High dynamic range (HDR), also known as wide dynamic range, extended dynamic range, or expanded dynamic range, is a signal with a higher dynamic range than usual. The term is often used in discussing the dynamic ranges of images, videos, audio o ...
, wide colour gamuts, and large colour depths. JPEG XL is also very efficient at decoding, and provides smooth transitions from the formats it intends to replace, losslessly able to convert from JPEG. It also excels at compressing without compromising on fidelity.


TIFF

Tag Image File Format Tag Image File Format or Tagged Image File Format, commonly known by the abbreviations TIFF or TIF, is an image file format for storing raster graphics images, popular among graphic artists, the publishing industry, and photographers. TIFF is w ...
(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). The high level of extensibility also means that most applications provide only a subset of possible features, potentially creating user confusion and compatibility issues. The most common general-purpose, lossless compression algorithm used with TIFF is
Lempel–Ziv–Welch Lempel–Ziv–Welch (LZW) 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 Lem ...
(LZW). This compression technique, also used in GIF, was covered by patents until 2003. TIFF also supports the compression algorithm PNG uses (i.e. Compression Tag 000816 '
Adobe Adobe (from arabic: الطوب Attub ; ) is a building material made from earth and organic materials. is Spanish for mudbrick. In some English-speaking regions of Spanish heritage, such as the Southwestern United States, the term is use ...
-style') with medium usage and support by applications. TIFF also offers special-purpose lossless compression algorithms like CCITT Group IV, which can compress bilevel images (e.g., faxes or black-and-white text) better than PNG's compression algorithm. PNG supports non-premultiplied alpha only whereas TIFF also supports "associated" (premultiplied) alpha.


WebP

WebP WebP is a raster graphics file format developed by Google intended as a replacement for JPEG, PNG, and GIF file formats. It supports both lossy and lossless compression, as well as animation and alpha transparency. Google announced the WebP ...
is a format invented by
Google Google LLC (, ) is an American multinational corporation and technology company focusing on online advertising, search engine technology, cloud computing, computer software, quantum computing, e-commerce, consumer electronics, and artificial ...
that was intended to replace PNG, JPEG, and GIF. WebP files allow for both lossy and lossless compression, while PNG only allows for lossless compression. WebP also supports animation, something that only
GIF The Graphics Interchange Format (GIF; or , ) is a Raster graphics, bitmap Image file formats, image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released ...
files could previously accomplish. The main improvements of WebP over PNG, however, are the large reduction in file size and therefore faster loading times when embedded into websites. Google claims that lossless WebP images are 26% smaller than PNG files. WebP has received criticism for being incompatible with various image editing programs and social media websites, unlike PNG. WebP is also not supported across all web browsers, which may require web image hosters to create a fallback image to display to the user, negating the potential storage savings of WebP.


AVIF

AVIF is an image format developed by the Alliance for Open Media. AVIF was designed by the foundation to make up for the shortcomings of other image codecs, including PNG,
GIF The Graphics Interchange Format (GIF; or , ) is a Raster graphics, bitmap Image file formats, image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released ...
, and
WebP WebP is a raster graphics file format developed by Google intended as a replacement for JPEG, PNG, and GIF file formats. It supports both lossy and lossless compression, as well as animation and alpha transparency. Google announced the WebP ...
. AVIF is generally smaller in size than both WebP and PNG. AVIF supports animation while PNG does not. However, like WebP, AVIF is supported across fewer browsers and applications than PNG. Specifically, AVIF is supported by the most used browsers,
Microsoft Edge Microsoft Edge is a Proprietary Software, proprietary cross-platform software, cross-platform web browser created by Microsoft and based on the Chromium (web browser), Chromium open-source project, superseding Edge Legacy. In Windows 11, Edge ...
,
Firefox Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curr ...
, and
Google Chrome Google Chrome is a web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS, iOS, iPadOS, an ...
, but requires an additional download for use with
Microsoft Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
.


Software support

The official
reference implementation In the software development process, a reference implementation (or, less frequently, sample implementation or model implementation) is a program that implements all requirements from a corresponding specification. The reference implementation ...
of the PNG format is the
programming library In computing, a library is a collection of System resource, resources that can be leveraged during software development to implement a computer program. Commonly, a library consists of executable code such as compiled function (computer scienc ...
''
libpng libpng is the official Portable Network Graphics (PNG) reference library (originally called pnglib). It is a platform-independent library that contains C functions for handling PNG images. It supports almost all of PNG's features, is extensible, ...
''. It is published as free software under the terms of a
permissive free software license A permissive software license, sometimes also called BSD-like or BSD-style license, is a free-software license which instead of copyleft protections, carries only minimal restrictions on how the software can be used, modified, and redistributed, ...
. Therefore, it is usually found as an important system library in free operating systems.


Bitmap graphics editor support for PNG

The PNG format is widely supported by graphics programs, including
Adobe Photoshop Adobe Photoshop is a raster graphics editor developed and published by Adobe Inc., Adobe for Microsoft Windows, Windows and macOS. It was created in 1987 by Thomas Knoll, Thomas and John Knoll. It is the most used tool for professional digital ...
,
Corel Cascade Parent Limited, doing business as Alludo ( ), is a Canadian software company headquartered in Ottawa, Ontario, specializing in graphics processing. Formerly called the Corel Corporation ( ; from the abbreviation "Cowpland Research Laborat ...
's Photo-Paint and Paint Shop Pro, the
GIMP Gimp or GIMP may refer to: Clothing * Bondage suit, also called a gimp suit, a type of suit used in BDSM * Bondage mask, also called a gimp mask, often worn in conjunction with a gimp suit Embroidery and crafts * Gimp (thread), an ornamental tr ...
, GraphicConverter, Helicon Filter,
ImageMagick ImageMagick, invoked from the command line as magick, is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. ImageMagick was created by John Cristy in 1987, and it ...
,
Inkscape Inkscape is a vector graphics editor. It is used for both artistic and technical illustrations such as cartoons, clip art, logos, typography, diagrams, and flowcharts. It uses vector graphics to allow for sharp printouts and renderings at ...
, IrfanView, Pixel image editor, Paint.NET and Xara Photo & Graphic Designer and many others (including online graphic design platforms such as
Canva Canva is an Australian multinational proprietary software company that provides a graphic design platform that provides tools for creating social media graphics, presentations, postcards, promotional merchandise and websites. Launched in Austr ...
). Some programs bundled with popular
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
s which support PNG include
Microsoft Microsoft Corporation is an American multinational corporation and technology company, technology conglomerate headquartered in Redmond, Washington. Founded in 1975, the company became influential in the History of personal computers#The ear ...
's
Paint Paint is a material or mixture that, when applied to a solid material and allowed to dry, adds a film-like layer. As art, this is used to create an image or images known as a painting. Paint can be made in many colors and types. Most paints are ...
and
Apple An apple is a round, edible fruit produced by an apple tree (''Malus'' spp.). Fruit trees of the orchard or domestic apple (''Malus domestica''), the most widely grown in the genus, are agriculture, cultivated worldwide. The tree originated ...
's Photos/
iPhoto iPhoto is a discontinued image editing software application developed by Apple Inc. for use on its Mac OS X operating system. It was included with every Mac computer from 2002 to 2015, when it was replaced with Apple's Photos application in ...
and Preview, with the GIMP also often being bundled with popular
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
distributions.
Adobe Fireworks Adobe Fireworks (formerly Macromedia Fireworks) was a bitmap and vector graphics editor, which Adobe acquired in 2005. Fireworks was made for web designers for rapidly creating website prototypes and application interfaces. Its features includ ...
(formerly by
Macromedia Macromedia, Inc. was an American graphics, multimedia, and web development software company headquartered in San Francisco, California, that made products such as Adobe Flash, Flash and Adobe Dreamweaver, Dreamweaver. It was purchased by its riv ...
) 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 metadata 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 metadata for use on web pages, etc.


Web browser support for PNG

PNG support first appeared in 1997, in
Internet Explorer Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated as IE or MSIE) is a deprecation, retired series of graphical user interface, graphical web browsers developed by Microsoft that were u ...
4.0b1 (32-bit only for NT), and in
Netscape Netscape Communications Corporation (originally Mosaic Communications Corporation) was an American independent computer services company with headquarters in Mountain View, California, and then Dulles, Virginia. Its Netscape web browser was o ...
4.04. Despite calls by the
Free Software Foundation The Free Software Foundation (FSF) is a 501(c)(3) non-profit organization founded by Richard Stallman on October 4, 1985. The organisation supports the free software movement, with the organization's preference for software being distributed ...
and the
World Wide Web Consortium The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working together in ...
(W3C), tools such as gif2png, and campaigns such as Burn All GIFs, PNG adoption on websites was fairly slow due to late and buggy support in Internet Explorer, particularly regarding transparency. PNG is the most used image file format on the web since 2018. PNG compatible browsers include: Apple
Safari A safari (; originally ) is an overland journey to observe wildlife, wild animals, especially in East Africa. The so-called big five game, "Big Five" game animals of Africa – lion, African leopard, leopard, rhinoceros, African elephant, elep ...
,
Google Chrome Google Chrome is a web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macOS, iOS, iPadOS, an ...
,
Mozilla Firefox Mozilla Firefox, or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. It uses the Gecko rendering engine to display web pages, which implements curren ...
,
Opera Opera is a form of History of theatre#European theatre, Western theatre in which music is a fundamental component and dramatic roles are taken by Singing, singers. Such a "work" (the literal translation of the Italian word "opera") is typically ...
, Camino,
Internet Explorer Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated as IE or MSIE) is a deprecation, retired series of graphical user interface, graphical web browsers developed by Microsoft that were u ...
,
Microsoft Edge Microsoft Edge is a Proprietary Software, proprietary cross-platform software, cross-platform web browser created by Microsoft and based on the Chromium (web browser), Chromium open-source project, superseding Edge Legacy. In Windows 11, Edge ...
and many others. For the complete comparison, see Comparison of web browsers (Image format support). Especially versions of Internet Explorer (Windows) below 9.0 (released 2011) had numerous problems which prevented it from correctly rendering PNG images. * 4.0 crashes on large PNG chunks. * 4.0 does not include the functionality to view .png files, but there is a registry fix. * 5.0 and 5.01 have broken OBJECT support. * 5.01 prints palette images with black (or dark gray) backgrounds under Windows 98, sometimes with radically altered colors. * 6.0 fails to display PNG images of 4097 or 4098 bytes in size. * 6.0 cannot open a PNG file that contains one or more zero-length IDAT chunks. This issue was first fixed in security update 947864 (MS08-024). For more information, see this article in the Microsoft Knowledge Base
947864
MS08-024: Cumulative Security Update for Internet Explorer. * 6.0 sometimes completely loses ability to display PNGs, but there are various fixes. * 6.0 and below have broken alpha-channel transparency support (will display the default background color instead). * 7.0 and below cannot combine 8-bit alpha transparency AND element opacity ( CSS – filter: Alpha (opacity=xx)) without filling partially transparent sections with black. * 8.0 and below have inconsistent/broken gamma support. * 8.0 and below don't have color-correction support.


Operating system support for PNG icons

PNG icons have been supported in most distributions of
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
since at least 1999, in desktop environments such as
GNOME A gnome () is a mythological creature and diminutive spirit in Renaissance magic and alchemy, introduced by Paracelsus in the 16th century and widely adopted by authors, including those of modern fantasy literature. They are typically depict ...
. In 2006,
Microsoft Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
support for PNG icons was introduced in
Windows Vista Windows Vista is a major release of the Windows NT operating system developed by Microsoft. It was the direct successor to Windows XP, released five years earlier, which was then the longest time span between successive releases of Microsoft W ...
. PNG icons are supported in
AmigaOS 4 AmigaOS 4 (abbreviated as OS4 or AOS4) is a line of Amiga operating systems which runs on PowerPC microprocessors. It is mainly based on AmigaOS 3.1 source code developed by Commodore International, Commodore, and partially on version 3.9 develop ...
, AROS,
macOS macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
,
iOS Ios, Io or Nio (, ; ; locally Nios, Νιός) is a Greek island in the Cyclades group in the Aegean Sea. Ios is a hilly island with cliffs down to the sea on most sides. It is situated halfway between Naxos and Santorini. It is about long an ...
and
MorphOS MorphOS is an AmigaOS-like operating system designed for Power and PowerPC based computers. The core, based on the Quark microkernel, is proprietary, although several libraries and other parts are open source, such as the Ambient desktop. The p ...
as well. In addition, Android makes extensive use of PNGs.


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 The Graphics Interchange Format (GIF; or , ) is a Raster graphics, bitmap Image file formats, image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released ...
files, a PNG file with the same information (256 colors, no ancillary chunks/metadata), compressed by an effective compressor is normally smaller than a GIF image. 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 compared to GIF's LZW, 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. However, some versions of
Adobe Photoshop Adobe Photoshop is a raster graphics editor developed and published by Adobe Inc., Adobe for Microsoft Windows, Windows and macOS. It was created in 1987 by Thomas Knoll, Thomas and John Knoll. It is the most used tool for professional digital ...
,
CorelDRAW CorelDRAW is a vector graphics editor developed and marketed by Alludo (formerly Corel Corporation). It is also the name of the Corel graphics suite, which includes the bitmap-image editor Corel Photo-Paint as well as other graphics-related progr ...
and
MS Paint Microsoft Paint (commonly known as MS Paint or simply Paint) is a simple raster graphics editor that has been included with all versions of Microsoft Windows. The program opens, modifies and saves image files in Windows bitmap (BMP), JPEG, GI ...
provide poor PNG compression, creating the impression that GIF is more efficient.


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.The filtering is used to increase the similarity to the data, hence increasing the compression ratio. However, there is theoretically no formula for similarity, nor absolute relationship between the similarity and compressor, thus unless the compression is done, one can't tell one filter set is better than another. ;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, different trade-offs are chosen: 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.


Lossy PNG compression

Although PNG is a lossless format, PNG encoders can preprocess image data in a lossy fashion to improve PNG compression. For example, quantizing a truecolor PNG to 256 colors allows the indexed color type to be used for a likely reduction in file size.


Image editing software

Some programs are more efficient than others when saving PNG files, this relates to implementation of the PNG compression used by the program. Many graphics programs (such as Apple's Preview software) save PNGs with large amounts of
metadata Metadata (or metainformation) is "data that provides information about other data", but not the content of the data itself, such as the text of a message or the image itself. There are many distinct types of metadata, including: * Descriptive ...
and color-correction data that are generally unnecessary for
Web Web most often refers to: * Spider web, a silken structure created by the animal * World Wide Web or the Web, an Internet-based hypertext system Web, WEB, or the Web may also refer to: Computing * WEB, a literate programming system created by ...
viewing. Unoptimized PNG files from
Adobe Fireworks Adobe Fireworks (formerly Macromedia Fireworks) was a bitmap and vector graphics editor, which Adobe acquired in 2005. Fireworks was made for web designers for rapidly creating website prototypes and application interfaces. Its features includ ...
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 is a raster graphics editor developed and published by Adobe Inc., Adobe for Microsoft Windows, Windows and macOS. It was created in 1987 by Thomas Knoll, Thomas and John Knoll. It is the most used tool for professional digital ...
'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). Adobe's Fireworks saves larger PNG files than many programs by default. This stems from the mechanics of its ''Save'' format: the images produced by Fireworks' save function include large, private chunks, containing complete layer and vector information. This allows further lossless editing. When 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. Other notable examples of poor PNG compressors include: * Microsoft's Paint for Windows XP * Microsoft Picture It! Photo Premium 9 Poor compression increases the PNG file size but does not affect the image quality or compatibility of the file with other programs. When the color depth of a truecolor image is reduced to an 8-bit palette (as in GIF), the resulting image data is typically much smaller. Thus a truecolor PNG is typically larger than a color-reduced GIF, although PNG could store the color-reduced version as a palettized file of comparable size. Conversely, some tools, when saving images as PNGs, automatically save them as truecolor, even if the original data use only 8-bit color, thus bloating the file unnecessarily. Both factors can lead to the misconception that PNG files are larger than equivalent GIF files.


Optimizing tools

Various tools are available for optimizing PNG files; they do this by: * (optionally) removing ancillary chunks, * reducing
color depth Color depth, also known as bit depth, is either the number of bits used to indicate the color of a single pixel, or the number of bits used for each color component of a single pixel. When referring to a pixel, the concept can be defined as bit ...
, 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.


Tool list

* pngcrush is the oldest of the popular PNG optimizers. It allows for multiple trials on filter selection and compression arguments, and finally chooses the smallest one. This working model is used in almost every png optimizer. * advpng and the similar advdef utility in the AdvanceCOMP package recompress the PNG IDAT. Different DEFLATE implementations are applied depending on the selected compression level, trading between speed and file size: zlib at level 1, libdeflate at level 2,
7-zip 7-Zip is a free and open-source file archiver, a utility used to place groups of files within compressed containers known as "archives". It is developed by Igor Pavlov and was first released in 1999. 7-Zip has its own Archive file, archive forma ...
's LZMA DEFLATE at level 3, and zopfli at level 4. * pngout was made with the author's own deflater (same to the author's zip utility, kzip), while keeping all facilities of color reduction / filtering. However, pngout doesn't allow for using several trials on filters in a single run. It's suggested to use its commercial GUI version, pngoutwin, or used with a wrapper to automate the trials or to recompress using its own deflater while keep the filter line by line.Use pngout -f6 to reuse previous filter set * zopflipng was also made with its own deflater, zopfli. It has all the optimizing features pngcrush has (including automating trials) while providing a very good, but slow deflater. A simple comparison of their features is listed below. Before zopflipng was available, a good way in practice to perform a png optimization is to use a combination of 2 tools in sequence for optimal compression: one which optimizes filters (and removes ancillary chunks), and one which optimizes DEFLATE. Although pngout offers both, only one type of filter can be specified in a single run, therefore it can be used with a wrapper tool or in combination with pngcrush, acting as a re-deflater, like advdef.


Ancillary chunk removal

For removing ancillary chunks, most PNG optimization tools 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. For example, the following command line options achieve this with pngcrush: pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB ''InputFile.png'' ''OutputFile.png''


Filter optimization

pngcrush, pngout, and zopflipng all offer options applying one of the filter types 0–4 globally (using the same filter type for all lines) or with a "pseudo filter" (numbered 5), which for each line chooses one of the filter types 0–4 using an adaptive algorithm. Zopflipng offers 3 different adaptive method, including a brute-force search that attempts to optimize the filtering. pngout-f OR zopflipng --filters pngout and zopflipng provide an option to preserve/reusezopflipng --filters=p the line-by-line filter set present in the input image. pngcrush and zopflipng provide options to try different filter strategies in a single run and choose the best. The freeware command line version of pngout doesn't offer this, but the commercial version, pngoutwin, does.Pngoutwin's setting dialog for optimization offers the user a selection of filter strategies.


DEFLATE optimization

Zopfli and the LZMA SDK provide DEFLATE implementations that can produce higher
compression ratio The compression ratio is the ratio between the maximum and minimum volume during the compression stage of the power cycle in a piston or Wankel engine. A fundamental specification for such engines, it can be measured in two different ways. Th ...
s than the
zlib zlib ( or "zeta-lib", ) is a software library used for data compression as well as a data format. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compre ...
reference implementation at the cost of performance. AdvanceCOMP's advpng and advdef can use either of these libraries to re-compress PNG files. Additionally, PNGOUT contains its own proprietary DEFLATE implementation. advpng doesn't have an option to apply filters and always uses filter 0 globally (leaving the image data unfiltered); therefore it should not be used where the image benefits significantly from filtering. By contrast, advdef from the same package doesn't deal with PNG structure and acts only as a re-deflater, retaining any existing filter settings.


Icon optimization

Since
icons An icon () is a religious work of art, most commonly a painting, in the cultures of the Eastern Orthodox, Oriental Orthodox, Catholic, and Lutheran churches. The most common subjects include Jesus, Mary, saints, and angels. Although especially ...
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 In computing, an icon is a pictogram or ideogram displayed on a computer screen in order to help the user navigate a computer system. It can serve as an electronic hyperlink or file shortcut to access the program or data. The user can activate ...
, Pixelformer, is able to perform a special optimization pass while saving ICO files, thereby reducing their sizes. Icons for macOS may also contain PNG subimages, yet there isn't such tool available.


See also

*
Computer graphics Computer graphics deals with generating images and art with the aid of computers. Computer graphics is a core technology in digital photography, film, video games, digital art, cell phone and computer displays, and many specialized applications. ...
, including: *
Image editing Image editing encompasses the processes of altering images, whether they are Digital photography, digital photographs, traditional Photographic processing, photo-chemical photographs, or illustrations. Traditional analog image editing is known ...
*
Image file format An image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be co ...
s * Related
graphics file format An image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be c ...
s ** APNG Animated PNG **
JPEG Network Graphics JPEG Network Graphics (JNG, ) is a JPEG-based graphics file format which is closely related to PNG: it uses the PNG file structure (with a different signature) as a container format to wrap JPEG-encoded image data. JNG was created as an adjunct ...
(JNG) **
Multiple-image Network Graphics Multiple-image Network Graphics (MNG) is a graphics file format published in 2001 for animated images. Its specification is publicly documented and there are free software reference implementations available. MNG is closely related to the PNG ...
(MNG) * Similar file formats ** X PixMap for portable icons *
Scalable Vector Graphics Scalable Vector Graphics (SVG) is an XML-based vector graphics format for defining two-dimensional graphics, having support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium sin ...
*
WebP WebP is a raster graphics file format developed by Google intended as a replacement for JPEG, PNG, and GIF file formats. It supports both lossy and lossless compression, as well as animation and alpha transparency. Google announced the WebP ...


Explanatory notes


References


Further reading

* * *


External links


PNG Specification

PNG Home Site






*
More information about PNG color correction

The GD-library to generate dynamic PNG-files with PHP



Encoding Web Shells in PNG files
Encoding human readable data inside an IDAT block. {{Authority control Computer-related introductions in 1996 Graphics standards Image compression ISO standards Open formats Raster graphics file formats World Wide Web Consortium standards