# Media : PNG \[ Wikpedia : [PNG](https://en.wikipedia.org/wiki/PNG) | [APNG](https://en.wikipedia.org/wiki/Animated_Portable_Network_Graphics) | [Spec](https://www.w3.org/TR/png/) ] — (Animated) Portable Network Graphics [Magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#In_files): ``` 89 50 4e 47 0d 0a 1a 0a (8 bytes) P N G ``` #### Summary - raster - lossless compression - multiple color models (w & wo palette) - data organized in chunks w/CRC (good for streaming) - arbitrary metadata - optional interlacing (to get progressive detail on slow connections) #### Image Types - palette-based (24b RGB | 32b RGBA) - grayscale (w/optional alpha channel) - full-color (not-palette-based) (24b RGB | 32b RGBA) ## Format ``` header chunks (critical | ancillary - can be ignored) 4B : length (L) 4B : chunk type / name LB : chunk data data 4B : CRC first chunk -> IHDR 4B width 4b height 1B bit depth (values: 1, 2, 4, 8, 16) 1B color type ( values: 0, 2, 3, 4, 6) 1B compression method (0) 1B filter method (0) 1B interlace method (0 -> no, 1 -> Adam7) last chunk -> IEND 0 bytes data ``` #### Chunk Types ``` # Critical IHDR Image header PLTE Palette IDAT Image data IEND Image trailer # Ancillary tRNS Transparency cHRM Primary chromaticities and white point gAMA Image gamme iCCP Embedded ICC profile sBIT Significant bits sRGB Standard RGB color space cICP Cpdomg=independent code points for video signal type identification mDCV Mastering Display Color Volume cLLI Content Light Level Information tEXt Textual data — one key/value pair per chunk, represented in ISO/IEC 8859-1 (Latin-1) "key" must be between one and 79 characters long separator is a null character "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 zTXt Compressed textual data iTXt International textual data — semantically equivalent to tEXt and zTXt, but UTF-8 instead of Latin-1 bKGD Background color hIST Image histogram pHYs Physical pixel dimensions sPLT Suggested palette eXIf Exif metadata tIME Image last-modification time # Animation-Related acTL Animation Control Chunk fcTL Frame Control Chunk fdAT Frame Data Chunk ``` ## APNG (Animated) TODO