Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
PNG
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== "Chunks" within the file === After the header, comes a series of [[Chunk (information)|chunks]],{{Sfn|W3C|2003|loc=[https://www.w3.org/TR/PNG/#5Chunk-layout 5.3 Chunk layout]}} 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 (digital)|container format]] or to [[Amiga]]{{'}}s [[Interchange File Format|IFF]], is designed to allow the PNG format to be extended while maintaining compatibility with older versions—it provides [[forward compatibility]], and this same file structure (with different signature and chunks) is used in the associated [[Multiple-image Network Graphics|MNG]], [[JPEG Network Graphics|JNG]], and [[APNG]] formats. A chunk consists of four parts: length (4 bytes,<ref name="PoCorGTFO">{{Cite book|url=https://books.google.com/books?id=lvMxDwAAQBAJ&pg=PT686|title=PoC or GTFO|isbn=9781593278984|quote=Each chunk consists of four parts: Length, a Chunk Type, the Chunk Data, and a 32-bit CRC. The Length is a 32-bit unsigned integer indicating the size of only the Chunk Data field|last1=Laphroaig|first1=Manul|date=31 October 2017|publisher=No Starch Press}}</ref> [[Endianness|big-endian]]), chunk type/name (4 bytes<ref>{{Cite book |url=https://books.google.com/books?id=lvMxDwAAQBAJ&pg=PT686|quote=Chunk Type is a 32-bit FourCC code such as IHDR, IDAT, or IEND.|title=PoC or GTFO|isbn=9781593278984|last1=Laphroaig|first1=Manul|date=31 October 2017|publisher=No Starch Press}}</ref>), chunk data (length bytes) and [[cyclic redundancy check|CRC]] (cyclic redundancy code/checksum; 4 bytes<ref name="PoCorGTFO" />). The CRC is a network-byte-order [[Computation of cyclic redundancy checks|CRC-32]] computed over the chunk type and chunk data, but not the length. {| class="wikitable" style="text-align: center;" |- ! style="width: 8em" | Length ! style="width: 8em" | Chunk type ! style="width: 16em"| Chunk data ! style="width: 8em" | CRC |- | 4 bytes | 4 bytes | ''Length'' bytes | 4 bytes |} Chunk types are given a four-letter [[Case sensitivity|case sensitive]] ASCII type/name; compare [[FourCC]]. The case of the different letters in the name (bit 5 of the numeric value of the character) is a [[bit field]] that provides the [[Codec|decoder]] 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. * <code>IHDR</code> 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).<ref name="w3IHDR">{{Harvnb|W3C|2003|loc=[https://www.w3.org/TR/PNG/#11IHDR 11.2.2 <code>IHDR</code> Image header]}}</ref> As stated in the [[World Wide Web Consortium]], bit depth is defined as "the number of bits per sample or per palette index (not per pixel)".<ref name="w3IHDR"/> * <code>PLTE</code> contains the [[Palette (computing)|palette]]: a list of colors. * <code>IDAT</code> 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.{{Sfn|W3C|2003|loc=[https://www.w3.org/TR/PNG/#11IDAT 11.2.4 <code>IDAT</code> Image data]}} * <code>IEND</code> marks the image end; the data field of the IEND chunk has 0 bytes/is empty.{{Sfn|W3C|2003|loc=[https://www.w3.org/TR/PNG/#11IEND 11.2.5 <code>IEND</code> Image trailer]}} The <code>PLTE</code> 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 correction|gamma]] values, background color, and textual [[metadata]] information. PNG also supports [[color management]] through the inclusion of [[ICC profile|ICC color profiles]].{{Sfn|W3C|2003|loc=[https://www.w3.org/TR/PNG/#11iCCP 11.3.3.3 <code>iCCP</code> Embedded ICC profile]}} * <code>bKGD</code> 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). * <code>cHRM</code> gives the [[chromaticity]] coordinates of the display [[Primary color|primaries]] and [[white point]]. * <code>cICP</code> specifies the color space, transfer function and matrix coefficients as defined in ITU-T [[H.273]].<ref>{{Cite web |date=2023-09-21 |title=PNG Specification (Third Edition), cICP Coding-independent code points for video signal type identification |url=https://www.w3.org/TR/png/#cICP-chunk |website=w3.org}}</ref> It is intended for use with [[High-dynamic-range television|HDR imagery]] without requiring a color profile.<ref>{{Cite web |date=2023-05-03 |title=Adding support for HDR imagery to the PNG format |url=https://github.com/w3c/ColorWeb-CG/blob/08d0981ae5163b76275d0777d0166eab85396371/hdr-in-png-requirements.md |publisher=W3C Color on the Web Community Group}}</ref> * <code>dSIG</code> is for storing digital signatures.<ref>{{Cite web|last=Thomas Kopp|date=17 April 2008|title=PNG Digital Signatures: Extension Specification|url=http://libpng.download/documents/signatures/}}</ref> * <code>eXIf</code> stores [[Exif]] metadata.<ref>{{Cite web|url=http://ftp-osl.osuosl.org/pub/libpng/documents/pngext-1.5.0.html|title=Extensions to the PNG 1.2 Specification, version 1.5.0|website=ftp-osl.osuosl.org}}</ref> * <code>gAMA</code> specifies [[Gamma correction|gamma]]. 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.{{Sfn|W3C|2003|loc=[https://www.w3.org/TR/PNG/#11gAMA 11.3.3.2 <code>gAMA</code> Image gamma]}} * <code>hIST</code> can store the histogram, or total amount of each color in the image. * <code>iCCP</code> is an [[ICC color profile]]. * <code>iTXt</code> contains a keyword and [[UTF-8]] text, with encodings for possible compression and translations marked with [[IETF language tag|language tag]]. The [[Extensible Metadata Platform]] (XMP) uses this chunk with a keyword 'XML:com.adobe.xmp' * <code>pHYs</code> 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.{{Sfn|W3C|2003|loc=[https://www.w3.org/TR/PNG/#11pHYs 11.3.5.3 <code>pHYs</code> Physical pixel dimensions]}} * <code>sBIT</code> (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.{{Sfn|W3C|2003|loc=[https://www.w3.org/TR/PNG/#11sBIT 11.3.3.4 <code>sBIT</code> Significant bits]}}<ref>{{cite web |url=https://www.w3.org/TR/PNG-Chunks.html |title=PNG (Portable Network Graphics) Specification \ Version 1.0 |website=w3.org |access-date=30 May 2022}} 4.2.6. sBIT Significant bits, 13 bytes total - color type 2 and 3 totaled 6 bytes</ref>{{Sfn|Roelofs|2003|loc=[http://libpng.org/pub/png/book/chapter11.html#png.ch11.div.7 Significant Bits (sBIT)]|postscript="Grayscale images are the simplest; sBIT then contains a single byte indicating the number of significant bits in the source data"}} * <code>sPLT</code> suggests a palette to use if the full range of colors is unavailable. * <code>sRGB</code> 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).<ref>{{Cite web|url=http://libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.sRGB|title = PNG Specification: Chunk Specifications}}</ref> * <code>sTER</code> stereo-image indicator chunk for [[stereoscopic]] images.<ref>{{Cite web|title=PNG News from 2006|url=http://libpng.org/pub/png/png2006.html|publisher=Libpng.org}}</ref> * <code>tEXt</code> can store text that can be represented in [[ISO/IEC 8859-1]], with one [[Attribute–value pair|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. * <code>tIME</code> stores the time that the image was last changed. * <code>tRNS</code> 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. * <code>zTXt</code> contains compressed text (and a compression method marker) with the same limits as <code>tEXt</code>. 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.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
PNG
(section)
Add topic