PNG
PNG¶
http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html
Header¶
- 89: Has the high bit set to detect transmission systems that do not support 8-bit data and to reduce the chance that a text file is mistakenly interpreted as a PNG, or vice versa.
- 50 4E 47: In ASCII, the letters PNG, allowing a person to identify the format easily if it is viewed in a text editor.
- 0D 0A: A DOS-style line ending (CRLF) to detect DOS-Unix line ending conversion of the data.
- 1A: A byte that stops display of the file under DOS when the command type has been used—the end-of-file character.
- 0A: A Unix-style line ending (LF) to detect Unix-DOS line ending conversion.
Chunks¶
- Length of Chunk
- 00 00 00 0D: 32-bit Integer
- Chunk Type
- 49 48 44 52 (IHDR): Is the first chunk
- Image Width: 32-bit integer
- Image Height: 32-bit integer
- Bit Depth: 8-bit Intager
- 01: Uses a Single Bit for each Color. Used in Grey scale and Pallet only
- 02: Uses Two Bits for each Color. Used in Grey scale and Pallet only
- 04: Uses Four Bits for each Color. Used in Grey scale and Pallet only
- 08: Uses 1 Byte for each Color. Used in all color types.
- 10: Uses 2 Bytes for each Color. Used in all color types except pallet.
- Color Type:
- 00: Grey Scale only
- 02: Uses (R,G,B) Triple
- 03: Uses a palette index
- 04: Grey Scale with Alpha Channel
- 06: Uses (R,G,B,A) Quad
- 50 4c 54 45 (PLTE): contains the palette: a list of colors.
- 49 44 41 54 (IDAT): contains the image, which may be split among multiple IDAT chunks. Such splitting increases filesize slightly, 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.
- 49 45 4e 44 (IEND): marks the image end; the data field of the IEND chunk has 0 bytes/is empty.
- 62 4b 47 44 (bKGD): gives the default background color.
- 63 48 52 4d (cHRM): gives the chromaticity coordinates of the display primaries and white point.
- 64 53 49 47 (dSIG): used for storing digital signatures.
- 65 58 49 66 (eXIf): stores Exif metadata.
- 67 41 4d 41 (gAMA): specifies gamma.
- 68 49 53 54 (hIST): can store the histogram, or total amount of each color in the image.
- 69 43 43 50 (iCCP): is an ICC color profile.
- 69 54 58 74 (iTXt): contains a keyword and UTF-8 text, with encodings for possible compression and translations marked with language tag. The Extensible Metadata Platform (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. - 73 42 49 54 (sBIT): Short for significant bits. Indicates the color-accuracy of the source data; this chunk contains a total of between 1 and 13 bytes.
- 73 50 4c 54 (sPLT): suggests a palette to use if the full range of colors is unavailable.
- 73 52 47 42 (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).
- 73 54 45 52 (sTER): stereo-image indicator chunk for stereoscopic images.
- 74 45 58 74 (tEXt): can store text that can be represented in ISO/IEC 8859-1, with one key-value pair for each chunk. The "key" must be between 1 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.
- 74 49 4d 45 (tIME): stores the time that the image was last changed.
- 74 52 4e 53 (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.
- 7a 54 58 74 (zTXt): contains compressed text (and a compression method marker) with the same limits as tEXt.
- 49 48 44 52 (IHDR): Is the first chunk
- Chunk Data
- CRC
- 00 01 02 03: CRC32 both the
Chunk Type
andChunk Data
- 00 01 02 03: CRC32 both the