CINXE.COM
Portable Network Graphics (PNG) Specification (Third Edition)
<!DOCTYPE html><html lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="generator" content="ReSpec 35.2.2"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <style> span.example-title{text-transform:none} :is(aside,div).example,div.illegal-example{padding:.5em;margin:1em 0;position:relative;clear:both} div.illegal-example{color:red} div.illegal-example p{color:#000} aside.example div.example{border-left-width:.1em;border-color:#999;background:#fff} </style> <style> .issue-label{text-transform:initial} .warning>p:first-child{margin-top:0} .warning{padding:.5em;border-left-width:.5em;border-left-style:solid} span.warning{padding:.1em .5em .15em} .issue.closed span.issue-number{text-decoration:line-through} .issue.closed span.issue-number::after{content:" (Closed)";font-size:smaller} .warning{border-color:#f11;border-color:var(--warning-border,#f11);border-width:.2em;border-style:solid;background:#fbe9e9;background:var(--warning-bg,#fbe9e9);color:#000;color:var(--text,#000)} .warning-title:before{content:"⚠";font-size:1.3em;float:left;padding-right:.3em;margin-top:-.3em} li.task-list-item{list-style:none} input.task-list-item-checkbox{margin:0 .35em .25em -1.6em;vertical-align:middle} .issue a.respec-gh-label{padding:5px;margin:0 2px 0 2px;font-size:10px;text-transform:none;text-decoration:none;font-weight:700;border-radius:4px;position:relative;bottom:2px;border:none;display:inline-block} </style> <style> dfn{cursor:pointer} .dfn-panel{position:absolute;z-index:35;min-width:300px;max-width:500px;padding:.5em .75em;margin-top:.6em;font-family:"Helvetica Neue",sans-serif;font-size:small;background:#fff;background:var(--indextable-hover-bg,#fff);color:#000;color:var(--text,#000);box-shadow:0 1em 3em -.4em rgba(0,0,0,.3),0 0 1px 1px rgba(0,0,0,.05);box-shadow:0 1em 3em -.4em var(--tocsidebar-shadow,rgba(0,0,0,.3)),0 0 1px 1px var(--tocsidebar-shadow,rgba(0,0,0,.05));border-radius:2px} .dfn-panel:not(.docked)>.caret{position:absolute;top:-9px} .dfn-panel:not(.docked)>.caret::after,.dfn-panel:not(.docked)>.caret::before{content:"";position:absolute;border:10px solid transparent;border-top:0;border-bottom:10px solid #fff;border-bottom-color:var(--indextable-hover-bg,#fff);top:0} .dfn-panel:not(.docked)>.caret::before{border-bottom:9px solid #a2a9b1;border-bottom-color:var(--indextable-hover-bg,#a2a9b1)} .dfn-panel *{margin:0} .dfn-panel b{display:block;color:#000;color:var(--text,#000);margin-top:.25em} .dfn-panel ul a[href]{color:#333;color:var(--text,#333)} .dfn-panel>div{display:flex} .dfn-panel a.self-link{font-weight:700;margin-right:auto} .dfn-panel .marker{padding:.1em;margin-left:.5em;border-radius:.2em;text-align:center;white-space:nowrap;font-size:90%;color:#040b1c} .dfn-panel .marker.dfn-exported{background:#d1edfd;box-shadow:0 0 0 .125em #1ca5f940} .dfn-panel .marker.idl-block{background:#8ccbf2;box-shadow:0 0 0 .125em #0670b161} .dfn-panel a:not(:hover){text-decoration:none!important;border-bottom:none!important} .dfn-panel a[href]:hover{border-bottom-width:1px} .dfn-panel ul{padding:0} .dfn-panel li{margin-left:1em} .dfn-panel.docked{position:fixed;left:.5em;top:unset;bottom:2em;margin:0 auto;max-width:calc(100vw - .75em * 2 - .5em - .2em * 2);max-height:30vh;overflow:auto} </style> <title>Portable Network Graphics (PNG) Specification (Third Edition)</title> <style type="text/css"> span.chunk { color: #622;} </style> <style id="respec-mainstyle"> @keyframes pop{ 0%{transform:scale(1,1)} 25%{transform:scale(1.25,1.25);opacity:.75} 100%{transform:scale(1,1)} } a.internalDFN{color:inherit;border-bottom:1px solid #99c;text-decoration:none} a.externalDFN{color:inherit;border-bottom:1px dotted #ccc;text-decoration:none} a.bibref{text-decoration:none} .respec-offending-element:target{animation:pop .25s ease-in-out 0s 1} .respec-offending-element,a[href].respec-offending-element{text-decoration:red wavy underline} @supports not (text-decoration:red wavy underline){ .respec-offending-element:not(pre){display:inline-block} .respec-offending-element{background:url(data:image/gif;base64,R0lGODdhBAADAPEAANv///8AAP///wAAACwAAAAABAADAEACBZQjmIAFADs=) bottom repeat-x} } #references :target{background:#eaf3ff;animation:pop .4s ease-in-out 0s 1} cite .bibref{font-style:normal} a[href].orcid{padding-left:4px;padding-right:4px} a[href].orcid>svg{margin-bottom:-2px} ol.tof,ul.tof{list-style:none outside none} .caption{margin-top:.5em;font-style:italic} #issue-summary>ul{column-count:2} #issue-summary li{list-style:none;display:inline-block} details.respec-tests-details{margin-left:1em;display:inline-block;vertical-align:top} details.respec-tests-details>*{padding-right:2em} details.respec-tests-details[open]{z-index:999999;position:absolute;border:thin solid #cad3e2;border-radius:.3em;background-color:#fff;padding-bottom:.5em} details.respec-tests-details[open]>summary{border-bottom:thin solid #cad3e2;padding-left:1em;margin-bottom:1em;line-height:2em} details.respec-tests-details>ul{width:100%;margin-top:-.3em} details.respec-tests-details>li{padding-left:1em} .self-link:hover{opacity:1;text-decoration:none;background-color:transparent} aside.example .marker>a.self-link{color:inherit} .header-wrapper{display:flex;align-items:baseline} :is(h2,h3,h4,h5,h6):not(#toc>h2,#abstract>h2,#sotd>h2,.head>h2){position:relative;left:-.5em} :is(h2,h3,h4,h5,h6):not(#toch2)+a.self-link{color:inherit;order:-1;position:relative;left:-1.1em;font-size:1rem;opacity:.5} :is(h2,h3,h4,h5,h6)+a.self-link::before{content:"§";text-decoration:none;color:var(--heading-text)} :is(h2,h3)+a.self-link{top:-.2em} :is(h4,h5,h6)+a.self-link::before{color:#000} @media (max-width:767px){ dd{margin-left:0} } @media print{ .removeOnSave{display:none} } </style> <meta name="color-scheme" content="light"> <meta name="description" content="This document describes PNG (Portable Network Graphics), an extensible file format for the lossless, portable, well-compressed storage of static and animated raster images. PNG provides a patent-free replacement for GIF and can also replace many common uses of TIFF. Indexed-color, greyscale, and truecolor images are supported, plus an optional alpha channel. Sample depths range from 1 to 16 bits."> <link rel="canonical" href="https://www.w3.org/TR/png-3/"> <style> .hljs{--base:#fafafa;--mono-1:#383a42;--mono-2:#686b77;--mono-3:#717277;--hue-1:#0b76c5;--hue-2:#336ae3;--hue-3:#a626a4;--hue-4:#42803c;--hue-5:#ca4706;--hue-5-2:#c91243;--hue-6:#986801;--hue-6-2:#9a6a01} @media (prefers-color-scheme:dark){ .hljs{--base:#282c34;--mono-1:#abb2bf;--mono-2:#818896;--mono-3:#5c6370;--hue-1:#56b6c2;--hue-2:#61aeee;--hue-3:#c678dd;--hue-4:#98c379;--hue-5:#e06c75;--hue-5-2:#be5046;--hue-6:#d19a66;--hue-6-2:#e6c07b} } .hljs{display:block;overflow-x:auto;padding:.5em;color:#383a42;color:var(--mono-1,#383a42);background:#fafafa;background:var(--base,#fafafa)} .hljs-comment,.hljs-quote{color:#717277;color:var(--mono-3,#717277);font-style:italic} .hljs-doctag,.hljs-formula,.hljs-keyword{color:#a626a4;color:var(--hue-3,#a626a4)} .hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#ca4706;color:var(--hue-5,#ca4706);font-weight:700} .hljs-literal{color:#0b76c5;color:var(--hue-1,#0b76c5)} .hljs-addition,.hljs-attribute,.hljs-meta-string,.hljs-regexp,.hljs-string{color:#42803c;color:var(--hue-4,#42803c)} .hljs-built_in,.hljs-class .hljs-title{color:#9a6a01;color:var(--hue-6-2,#9a6a01)} .hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#986801;color:var(--hue-6,#986801)} .hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#336ae3;color:var(--hue-2,#336ae3)} .hljs-emphasis{font-style:italic} .hljs-strong{font-weight:700} .hljs-link{text-decoration:underline} </style> <style> var{position:relative;cursor:pointer} var[data-type]::after,var[data-type]::before{position:absolute;left:50%;top:-6px;opacity:0;transition:opacity .4s;pointer-events:none} var[data-type]::before{content:"";transform:translateX(-50%);border-width:4px 6px 0 6px;border-style:solid;border-color:transparent;border-top-color:#222} var[data-type]::after{content:attr(data-type);transform:translateX(-50%) translateY(-100%);background:#222;text-align:center;font-family:"Dank Mono","Fira Code",monospace;font-style:normal;padding:6px;border-radius:3px;color:#daca88;text-indent:0;font-weight:400} var[data-type]:hover::after,var[data-type]:hover::before{opacity:1} </style> <script id="initialUserConfig" type="application/json">{ "group": "png", "specStatus": "CR", "publishDate": "2025-03-13", "crEnd": "2025-05-13", "implementationReportURI": "https://w3c.github.io/png/Implementation_Report_3e/", "shortName": "png-3", "copyrightStart": "1996", "previousPublishDate": "2025-01-21", "previousMaturity": "CRD", "edDraftURI": "https://w3c.github.io/png/", "github": { "repoURL": "https://github.com/w3c/png", "branch": "main" }, "extraCSS": [ "https://dev.w3.org/2009/dap/ReSpec.js/css/respec.css" ], "editors": [ { "name": "Chris Blume", "url": "https://www.programmax.net", "company": "W3C Invited Experts", "w3cid": 127631 }, { "name": "Pierre-Anthony Lemieux", "company": "MovieLabs", "companyURL": "https://movielabs.com/", "url": "mailto:pal@palemieux.com", "w3cid": 57073 }, { "name": "Chris Lilley", "url": "https://svgees.us", "company": "W3C", "companyURL": "https://www.w3.org", "w3cid": 1438 }, { "name": "Chris Needham", "url": "https://chrisneedham.com/about", "w3cid": 67414 }, { "name": "Leonard Rosenthol", "company": "Adobe Inc.", "companyURL": "https://www.adobe.com", "w3cid": 42485 }, { "name": "Chris Arley Seeger", "company": "NBCUniversal, LLC a subsidiary of Comcast Corporation", "companyURL": "https://www.xfinity.com", "w3cid": 125844 }, { "name": "Simon Thompson", "company": "British Broadcasting Corporation", "companyURL": "https://www.bbc.co.uk", "w3cid": 100939 }, { "name": "Cosmin Truta", "company": "W3C Invited Experts", "w3cid": 160971 } ], "formerEditors": [ { "name": "Thomas Boutell" }, { "name": "Adam M. Costello" }, { "name": "David Duce" }, { "name": "Tom Lane" }, { "name": "Glenn Randers-Pehrson" } ], "authors": [ { "name": "Mark Adler", "url": "https://en.wikipedia.org/wiki/Mark_Adler" }, { "name": "Thomas Boutell", "url": "https://boutell.dev/" }, { "name": "Christian Brunschen" }, { "name": "Adam M. Costello", "url": "http://www.nicemice.net/amc/" }, { "name": "Lee Daniel Crocker" }, { "name": "Andreas Dilger", "url": "http://www-mddsp.enel.ucalgary.ca/People/adilger/" }, { "name": "Oliver Fromme", "url": "https://www.fromme.com/" }, { "name": "Jean-loup Gailly", "url": "http://gailly.net/" }, { "name": "Phil Harvey" }, { "name": "Chris Herborth" }, { "name": "Alex Jakulin" }, { "name": "Neal Kettler" }, { "name": "Tom Lane" }, { "name": "Alexander Lehmann" }, { "name": "Chris Lilley", "url": "https://svgees.us", "company": "W3C", "companyURL": "https://www.w3.org" }, { "name": "Dave Martindale" }, { "name": "Owen Mortensen" }, { "name": "Stuart Parmenter" }, { "name": "Keith S. Pickens" }, { "name": "Robert P. Poole" }, { "name": "Glenn Randers-Pehrson" }, { "name": "Greg Roelofs", "url": "http://www.gregroelofs.com/" }, { "name": "Willem van Schaik" }, { "name": "Guy Schalnat" }, { "name": "Paul Schmidt" }, { "name": "Andrew Smith" }, { "name": "Michael Stokes" }, { "name": "Vladimir Vukicevic" }, { "name": "Tim Wegner" }, { "name": "Jeremy Wohl" } ], "wg": "Portable Network Graphics (PNG) Working Group", "wgURI": "https://www.w3.org/groups/wg/png", "wgPublicList": "public-png", "wgPatentURI": "https://www.w3.org/groups/wg/png/ipr", "lint": { "informative-dfn": false }, "xref": [ "i18n-glossary" ], "localBiblio": { "CIPA-DC-008": { "title": "Exchangeable image file format for digital still cameras: Exif Version 2.32", "href": "https://www.cipa.jp/std/documents/download_e.html?DC-008-Translation-2019-E", "date": "2019-05-17", "publisher": "Camera & Imaging Products Association", "id": "cipa-dc-008" }, "COLOR-FAQ": { "title": "Color FAQ", "authors": [ "Poynton, C." ], "href": "https://poynton.ca/ColorFAQ.html", "date": "2009-10-19", "id": "color-faq" }, "CTA-861.3-A": { "title": "HDR Static Metadata Extensions (CTA-861.3-A)", "publisher": "Consumer Technology Association", "date": "2015-01", "href": "https://shop.cta.tech/products/hdr-static-metadata-extensions", "id": "cta-861.3-a" }, "Display-P3": { "title": "Display P3", "authors": [ "Apple, Inc" ], "date": "2022-02", "publisher": "ICC", "href": "https://www.color.org/chardata/rgb/DisplayP3.xalter", "id": "display-p3" }, "ICC-2": { "title": "Specification ICC.2:2019 (Profile version 5.0.0 - iccMAX)", "date": "2019", "href": "https://www.color.org/specification/ICC.2-2019.pdf", "publisher": "International Color Consortium", "id": "icc-2" }, "GAMMA-FAQ": { "title": "Gamma FAQ", "authors": [ "Poynton, C." ], "href": "https://poynton.ca/GammaFAQ.html", "date": "1998-08-04", "id": "gamma-faq" }, "HDR10": { "title": "HDR10 Media Profile", "href": "https://en.wikipedia.org/wiki/HDR10", "id": "hdr10" }, "HDR-Static-Meta": { "title": "On the Calculation and Usage of HDR Static Content Metadata", "authors": [ "Smith, Michael D.", "Zink, Michael" ], "publisher": "Society of Motion Picture and Television Engineers", "date": "2021-08-05", "href": "https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9508136", "id": "hdr-static-meta" }, "Hill": { "title": "Comparative analysis of the quantization of color spaces on the basis of the CIELAB color-difference formula", "authors": [ "Hill, B.", "Roger, Th.", "Vorhagen, F.W." ], "journal": "ACM Transactions on Graphics, Volume 16, Issue 2, pp. 109–154", "date": "1997-04", "href": "https://dl.acm.org/doi/10.1145/248210.248212", "id": "hill" }, "ISO-3309": { "title": "ISO/IEC 3309:1993, Information Technology — Telecommunications and information exchange between systems — High-level data link control (HDLC) procedures — Frame structure.", "date": "1993", "publisher": "ISO", "id": "iso-3309" }, "ISO_8859-1": { "title": "ISO/IEC 8859-1:1998, Information technology — 8-bit single-byte coded graphic character sets — Part 1: Latin alphabet No. 1.", "date": "1998", "publisher": "ISO", "id": "iso_8859-1" }, "ISO_9899": { "title": "ISO/IEC 9899:2018 Information technology — Programming languages — C", "href": "https://www.iso.org/standard/74528.html", "date": "2018-6", "publisher": "ISO", "id": "iso_9899" }, "ISO_15076-1": { "title": "ISO 15076-1:2010 Image technology colour management — Architecture, profile format and data structure — Part 1: Based on ICC.1:2010", "href": "https://www.iso.org/standard/54754.html", "date": "2010-12", "publisher": "ISO", "id": "iso_15076-1" }, "ISO_20677-1": { "title": "ISO 20677:2019 Image technology colour management — Extensions to architecture, profile format and data structure", "href": "https://www.iso.org/standard/68806.html", "date": "2019-02", "publisher": "ISO" }, "ITU-R-BT.709": { "title": "ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange", "publisher": "ITU", "date": "2015-06", "href": "https://www.itu.int/rec/R-REC-BT.709", "id": "itu-r-bt.709" }, "ITU-R-BT.2020": { "title": "Parameter values for ultra-high definition television systems for production and international programme exchange", "publisher": "ITU", "href": "https://www.itu.int/rec/R-REC-BT.2020", "id": "itu-r-bt.2020" }, "ITU-R-BT.2100": { "title": "ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange", "publisher": "ITU", "date": "2018-07", "href": "https://www.itu.int/rec/R-REC-BT.2100", "id": "itu-r-bt.2100" }, "ITU-R-BT.2390": { "title": "High dynamic range television for production and international programme exchange", "publisher": "ITU", "href": "https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2390-11-2023-PDF-E.pdf", "id": "itu-r-bt.2390" }, "ITU-T-H.273": { "title": "ITU-T H.273, SERIES H: AUDIOVISUAL AND MULTIMEDIA SYSTEMS Infrastructure of audiovisual services – Coding of moving video. Coding-independent code points for video signal type identification", "publisher": "ITU", "date": "2024-07-14", "href": "https://www.itu.int/rec/T-REC-H.273", "id": "itu-t-h.273" }, "ITU-T-V.42": { "title": "ITU-T V.42, SERIES V: DATA COMMUNICATION OVER THE TELEPHONE NETWORK. Error-correcting procedures for DCEs using asynchronous-to-synchronous conversion", "href": "https://www.itu.int/rec/T-REC-V.42-200203-I/en", "date": "2002-03-29", "publisher": "ITU", "id": "itu-t-v.42" }, "Kasson": { "title": "An Analysis of Selected Computer Interchange Color Spaces", "authors": [ "Kasson, J.", "W. Plouffe" ], "journal": "ACM Transactions on Graphics, vol. 11, no. 4, pp. 373-405", "date": "1992", "href": "https://dl.acm.org/doi/abs/10.1145/146443.146479", "id": "kasson" }, "Luminance-Chromaticity": { "title": "Luminance and Chromaticity", "href": "https://colorusage.arc.nasa.gov/lum_and_chrom.php", "publisher": "Color Usage Research Lab, NASA Ames Research Center", "id": "luminance-chromaticity" }, "Paeth": { "authors": [ "Paeth, A.W" ], "title": "Image File Compression Made Easy, in Graphics Gems II, pp. 93-100", "publisher": "Academic Press", "date": "1991", "isbn": "0-12-064481-9", "href": "https://www.sciencedirect.com/science/article/pii/B9780080507545500293", "id": "paeth" }, "PNG-EXTENSIONS": { "title": "Extensions to the PNG Third Edition Specification, Version 1.6.0", "publisher": "W3C", "date": "2021", "href": "https://w3c.github.io/png/extensions/Overview.html", "id": "png-extensions" }, "PostScript": { "title": "PostScript Language Reference Manual", "authors": [ "Adobe Systems Incorporated" ], "publisher": "Addison-Wesley", "date": "1990", "edition": "2", "isbn": "0-201-18127-4", "id": "postscript" }, "ROELOFS": { "title": "PNG: The Definitive Guide", "authors": [ "Roelofs, G." ], "publisher": "O'Reilly & Associates Inc", "isbn": "1-56592-542-4", "href": "http://www.libpng.org/pub/png/pngbook.html", "date": "1999-06-11", "id": "roelofs" }, "SMPTE-170M": { "title": "Television — Composite Analog Video Signal — NTSC for Studio Applications", "publisher": "Society of Motion Picture and Television Engineers", "date": "2004-11-30", "href": "https://standards.globalspec.com/std/892300/SMPTE%20ST%20170M", "id": "smpte-170m" }, "SMPTE-RP-177": { "title": "Derivation of Basic Television Color Equations", "publisher": "Society of Motion Picture and Television Engineers", "date": "1 November 1993", "href": "https://standards.globalspec.com/std/1284890/smpte-rp-177", "id": "smpte-rp-177" }, "SMPTE-ST-2067-21": { "title": "Interoperable Master Format — Application #2E", "publisher": "Society of Motion Picture and Television Engineers", "date": "2023-02-20", "href": "https://doi.org/10.5594/SMPTE.ST2067-21.2023", "id": "smpte-st-2067-21" }, "SMPTE-RP-2077": { "title": "Full-Range Image Mapping", "publisher": "Society of Motion Picture and Television Engineers", "date": "2013-01-01", "href": "https://doi.org/10.5594/SMPTE.RP2077.2013", "id": "smpte-rp-2077" }, "SMPTE-ST-2086": { "title": "Mastering Display Color Volume Metadata Supporting High Luminance and Wide Color Gamut Images", "publisher": "Society of Motion Picture and Television Engineers", "date": "27 April 2018", "href": "https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8353899", "id": "smpte-st-2086" }, "TIFF-6.0": { "href": "https://www.loc.gov/preservation/digital/formats/fdd/fdd000022.shtml", "title": "TIFF Revision 6.0", "date": "3 June 1992", "id": "tiff-6.0" }, "Ziv-Lempel": { "authors": [ "J. Ziv", "A. Lempel" ], "title": "A Universal Algorithm for Sequential Data Compression, IEEE Transactions on Information Theory, vol. IT-23, no. 3, pp. 337 - 343", "date": "1977-05", "publisher": "IEEE", "href": "https://ieeexplore.ieee.org/document/1055714", "id": "ziv-lempel" }, "EBU-R-103": { "title": "Video Signal Tolerance in Digital Television Systems", "publisher": "EBU", "date": "2020-05", "href": "https://tech.ebu.ch/docs/r/r103.pdf", "id": "ebu-r-103" }, "ITU-T-Series-H-Supplement-19": { "title": "Series H: Audio Visual and Multimedia Systems - Usage of video signal type code points", "publisher": "ITU", "date": "2021-04", "href": "https://www.itu.int/ITU-T/recommendations/rec.aspx?rec=14652", "id": "itu-t-series-h-supplement-19" } }, "publishISODate": "2025-03-13T00:00:00.000Z", "generatedSubtitle": "W3C Candidate Recommendation Snapshot 13 March 2025" }</script> <link rel="stylesheet" href="https://www.w3.org/StyleSheets/TR/2021/W3C-CR"></head> <body class="h-entry" data-cite="i18n-glossary"><div class="head"> <p class="logos"><a class="logo" href="https://www.w3.org/"><img crossorigin="" alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2021/logos/W3C" width="72"> </a></p> <h1 id="title" class="title">Portable Network Graphics (PNG) Specification (Third Edition)</h1> <p id="w3c-state"><a href="https://www.w3.org/standards/types#CR">W3C Candidate Recommendation Snapshot</a> <time class="dt-published" datetime="2025-03-13">13 March 2025</time></p> <details open=""> <summary>More details about this document</summary> <dl> <dt>This version:</dt><dd> <a class="u-url" href="https://www.w3.org/TR/2025/CR-png-3-20250313/">https://www.w3.org/TR/2025/CR-png-3-20250313/</a> </dd> <dt>Latest published version:</dt><dd> <a href="https://www.w3.org/TR/png-3/">https://www.w3.org/TR/png-3/</a> </dd> <dt>Latest editor's draft:</dt><dd><a href="https://w3c.github.io/png/">https://w3c.github.io/png/</a></dd> <dt>History:</dt><dd> <a href="https://www.w3.org/standards/history/png-3/">https://www.w3.org/standards/history/png-3/</a> </dd><dd> <a href="https://github.com/w3c/png/commits/main">Commit history</a> </dd> <dt>Implementation report:</dt><dd> <a href="https://w3c.github.io/png/Implementation_Report_3e/">https://w3c.github.io/png/Implementation_Report_3e/</a> </dd> <dt>Editors:</dt><dd class="editor p-author h-card vcard" data-editor-id="127631"> <a class="u-url url p-name fn" href="https://www.programmax.net">Chris Blume</a> (<span class="p-org org h-org">W3C Invited Experts</span>) </dd><dd class="editor p-author h-card vcard" data-editor-id="57073"> <a class="ed_mailto u-email email p-name" href="mailto:pal@palemieux.com">Pierre-Anthony Lemieux</a> (<a class="p-org org h-org" href="https://movielabs.com/">MovieLabs</a>) </dd><dd class="editor p-author h-card vcard" data-editor-id="1438"> <a class="u-url url p-name fn" href="https://svgees.us">Chris Lilley</a> (<a class="p-org org h-org" href="https://www.w3.org">W3C</a>) </dd><dd class="editor p-author h-card vcard" data-editor-id="67414"> <a class="u-url url p-name fn" href="https://chrisneedham.com/about">Chris Needham</a> </dd><dd class="editor p-author h-card vcard" data-editor-id="42485"> <span class="p-name fn">Leonard Rosenthol</span> (<a class="p-org org h-org" href="https://www.adobe.com">Adobe Inc.</a>) </dd><dd class="editor p-author h-card vcard" data-editor-id="125844"> <span class="p-name fn">Chris Arley Seeger</span> (<a class="p-org org h-org" href="https://www.xfinity.com">NBCUniversal, LLC a subsidiary of Comcast Corporation</a>) </dd><dd class="editor p-author h-card vcard" data-editor-id="100939"> <span class="p-name fn">Simon Thompson</span> (<a class="p-org org h-org" href="https://www.bbc.co.uk">British Broadcasting Corporation</a>) </dd><dd class="editor p-author h-card vcard" data-editor-id="160971"> <span class="p-name fn">Cosmin Truta</span> (<span class="p-org org h-org">W3C Invited Experts</span>) </dd> <dt> Former editors: </dt><dd class="editor p-author h-card vcard"> <span class="p-name fn">Thomas Boutell</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Adam M. Costello</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">David Duce</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Tom Lane</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Glenn Randers-Pehrson</span> </dd> <dt>Authors:</dt><dd class="editor p-author h-card vcard"> <a class="u-url url p-name fn" href="https://en.wikipedia.org/wiki/Mark_Adler">Mark Adler</a> </dd><dd class="editor p-author h-card vcard"> <a class="u-url url p-name fn" href="https://boutell.dev/">Thomas Boutell</a> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Christian Brunschen</span> </dd><dd class="editor p-author h-card vcard"> <a class="u-url url p-name fn" href="http://www.nicemice.net/amc/">Adam M. Costello</a> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Lee Daniel Crocker</span> </dd><dd class="editor p-author h-card vcard"> <a class="u-url url p-name fn" href="http://www-mddsp.enel.ucalgary.ca/People/adilger/">Andreas Dilger</a> </dd><dd class="editor p-author h-card vcard"> <a class="u-url url p-name fn" href="https://www.fromme.com/">Oliver Fromme</a> </dd><dd class="editor p-author h-card vcard"> <a class="u-url url p-name fn" href="http://gailly.net/">Jean-loup Gailly</a> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Phil Harvey</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Chris Herborth</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Alex Jakulin</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Neal Kettler</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Tom Lane</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Alexander Lehmann</span> </dd><dd class="editor p-author h-card vcard"> <a class="u-url url p-name fn" href="https://svgees.us">Chris Lilley</a> (<a class="p-org org h-org" href="https://www.w3.org">W3C</a>) </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Dave Martindale</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Owen Mortensen</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Stuart Parmenter</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Keith S. Pickens</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Robert P. Poole</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Glenn Randers-Pehrson</span> </dd><dd class="editor p-author h-card vcard"> <a class="u-url url p-name fn" href="http://www.gregroelofs.com/">Greg Roelofs</a> </dd><dd class="editor p-author h-card vcard"> <a class="u-url url p-name fn" href="http://www.schaik.com/">Willem van Schaik</a> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Guy Schalnat</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Paul Schmidt</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Andrew Smith</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Michael Stokes</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Vladimir Vukicevic</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Tim Wegner</span> </dd><dd class="editor p-author h-card vcard"> <span class="p-name fn">Jeremy Wohl</span> </dd> <dt>Feedback:</dt><dd> <a href="https://github.com/w3c/png/">GitHub w3c/png</a> (<a href="https://github.com/w3c/png/pulls/">pull requests</a>, <a href="https://github.com/w3c/png/issues/new/choose">new issue</a>, <a href="https://github.com/w3c/png/issues/">open issues</a>) </dd><dd><a href="mailto:public-png@w3.org?subject=%5Bpng-3%5D%20YOUR%20TOPIC%20HERE">public-png@w3.org</a> with subject line <kbd>[png-3] <em>… message topic …</em></kbd> (<a rel="discussion" href="https://lists.w3.org/Archives/Public/public-png">archives</a>)</dd> </dl> </details> <p class="copyright"> <a href="https://www.w3.org/policies/#copyright">Copyright</a> © 1996-2025 <a href="https://www.w3.org/">World Wide Web Consortium</a>. <abbr title="World Wide Web Consortium">W3C</abbr><sup>®</sup> <a href="https://www.w3.org/policies/#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/policies/#W3C_Trademarks">trademark</a> and <a rel="license" href="https://www.w3.org/copyright/software-license-2023/" title="W3C Software and Document Notice and License">permissive document license</a> rules apply. </p> <hr title="Separator for header"> </div> <section id="abstract" class="introductory"><h2>Abstract</h2> <p>This document describes PNG (Portable Network Graphics), an extensible file format for the <a href="#dfn-lossless" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-lossless-1">lossless</a>, portable, well-compressed storage of static and animated raster images. PNG provides a patent-free replacement for GIF and can also replace many common uses of TIFF. <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-1">Indexed-color</a>, <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-1">greyscale</a>, and <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-1">truecolor</a> images are supported, plus an optional alpha channel. Sample depths range from 1 to 16 bits.</p> <p>PNG is designed to work well in online viewing applications, such as the World Wide Web, so it is fully streamable with a progressive display option. PNG is robust, providing both full file integrity checking and simple detection of common transmission errors. Also, PNG can store color space data for improved color matching on heterogeneous platforms.</p> <p>This specification defines two Internet Media Types, image/png and image/apng.</p> </section> <section id="sotd" class="introductory"><h2>Status of This Document</h2><p><em>This section describes the status of this document at the time of its publication. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the latest revision of this technical report can be found in the <a href="https://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports index</a> at https://www.w3.org/TR/.</em></p> <p>This specification is intended to become an International Standard, but is not yet one. It is inappropriate to refer to this specification as an International Standard.</p> <p> This document was published by the <a href="https://www.w3.org/groups/wg/png">Portable Network Graphics (PNG) Working Group</a> as a Candidate Recommendation Snapshot using the <a href="https://www.w3.org/policies/process/20231103/#recs-and-notes">Recommendation track</a>. </p><p>Publication as a Candidate Recommendation does not imply endorsement by <abbr title="World Wide Web Consortium">W3C</abbr> and its Members. A Candidate Recommendation Snapshot has received <a href="https://www.w3.org/policies/process/20231103/#dfn-wide-review">wide review</a>, is intended to gather <a href="https://w3c.github.io/png/Implementation_Report_3e/">implementation experience</a>, and has commitments from Working Group members to <a href="https://www.w3.org/policies/patent-policy/#sec-Requirements">royalty-free licensing</a> for implementations.</p><p> This Candidate Recommendation is not expected to advance to Proposed Recommendation any earlier than 13 May 2025. </p><p> This document was produced by a group operating under the <a href="https://www.w3.org/policies/patent-policy/"><abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>. <abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a rel="disclosure" href="https://www.w3.org/groups/wg/png/ipr">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href="https://www.w3.org/policies/patent-policy/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="https://www.w3.org/policies/patent-policy/#sec-Disclosure">section 6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>. </p><p> This document is governed by the <a id="w3c_process_revision" href="https://www.w3.org/policies/process/20231103/">03 November 2023 <abbr title="World Wide Web Consortium">W3C</abbr> Process Document</a>. </p></section><nav id="toc"><h2 class="introductory" id="table-of-contents">Table of Contents</h2><ol class="toc"><li class="tocline"><a class="tocxref" href="#abstract">Abstract</a></li><li class="tocline"><a class="tocxref" href="#sotd">Status of This Document</a></li><li class="tocline"><a class="tocxref" href="#Introduction"><bdi class="secno">1. </bdi>Introduction</a></li><li class="tocline"><a class="tocxref" href="#1Scope"><bdi class="secno">2. </bdi>Scope</a></li><li class="tocline"><a class="tocxref" href="#3Defsandabbrevs"><bdi class="secno">3. </bdi>Terms, definitions, and abbreviated terms</a></li><li class="tocline"><a class="tocxref" href="#4Concepts"><bdi class="secno">4. </bdi>Concepts</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#static-and-animated-images"><bdi class="secno">4.1 </bdi>Static and Animated images</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.Sourceimage"><bdi class="secno">4.2 </bdi>Images</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.ColourSpaces"><bdi class="secno">4.3 </bdi>Color spaces</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.PNGImageTransformation"><bdi class="secno">4.4 </bdi>Reference image to PNG image transformation</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#4Concepts.Introduction">Introduction</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.Implied-alpha"><bdi class="secno">4.4.1 </bdi><span>Alpha separation</span></a></li><li class="tocline"><a class="tocxref" href="#4Concepts.Indexing"><bdi class="secno">4.4.2 </bdi>Indexing</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.RGBMerging"><bdi class="secno">4.4.3 </bdi><span>RGB merging</span> </a></li><li class="tocline"><a class="tocxref" href="#4Concepts.Alpha-indexing"><bdi class="secno">4.4.4 </bdi><span>Alpha compaction</span></a></li><li class="tocline"><a class="tocxref" href="#4Concepts.Scaling"><bdi class="secno">4.4.5 </bdi><span>Sample depth scaling</span> </a></li></ol></li><li class="tocline"><a class="tocxref" href="#4Concepts.PNGImage"><bdi class="secno">4.5 </bdi>PNG image</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.Encoding"><bdi class="secno">4.6 </bdi>Encoding the PNG image</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#4Concepts.EncodingIntro">Introduction</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.EncodingPassAbs"><bdi class="secno">4.6.1 </bdi>Pass extraction</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.EncodingScanlineAbs"><bdi class="secno">4.6.2 </bdi>Scanline serialization</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.EncodingFiltering"><bdi class="secno">4.6.3 </bdi>Filtering</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.EncodingCompression"><bdi class="secno">4.6.4 </bdi>Compression</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.EncodingChunking"><bdi class="secno">4.6.5 </bdi>Chunking</a></li></ol></li><li class="tocline"><a class="tocxref" href="#4Concepts.AncillInfo"><bdi class="secno">4.7 </bdi>Additional information</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.Format"><bdi class="secno">4.8 </bdi>PNG datastream</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#4Concepts.FormatChunks"><bdi class="secno">4.8.1 </bdi>Chunks</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.FormatTypes"><bdi class="secno">4.8.2 </bdi>Chunk types</a></li></ol></li><li class="tocline"><a class="tocxref" href="#apng-frame-based-animation"><bdi class="secno">4.9 </bdi><abbr title="Animated PNG">APNG</abbr>: frame-based animation</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#introduction-0">Introduction</a></li><li class="tocline"><a class="tocxref" href="#structure"><bdi class="secno">4.9.1 </bdi>Structure</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.APNGSequence"><bdi class="secno">4.9.2 </bdi>Sequence numbers</a></li><li class="tocline"><a class="tocxref" href="#apng-output-buffer"><bdi class="secno">4.9.3 </bdi>Output buffer</a></li><li class="tocline"><a class="tocxref" href="#apng-canvas"><bdi class="secno">4.9.4 </bdi>Canvas</a></li></ol></li><li class="tocline"><a class="tocxref" href="#4Concepts.Errors"><bdi class="secno">4.10 </bdi>Error handling</a></li><li class="tocline"><a class="tocxref" href="#4Concepts.Registration"><bdi class="secno">4.11 </bdi>Extensions</a></li></ol></li><li class="tocline"><a class="tocxref" href="#5DataRep"><bdi class="secno">5. </bdi>Datastream structure</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#5Introduction"><bdi class="secno">5.1 </bdi>PNG datastream</a></li><li class="tocline"><a class="tocxref" href="#3PNGsignature"><bdi class="secno">5.2 </bdi>PNG signature</a></li><li class="tocline"><a class="tocxref" href="#5Chunk-layout"><bdi class="secno">5.3 </bdi>Chunk layout</a></li><li class="tocline"><a class="tocxref" href="#5Chunk-naming-conventions"><bdi class="secno">5.4 </bdi>Chunk naming conventions</a></li><li class="tocline"><a class="tocxref" href="#5CRC-algorithm"><bdi class="secno">5.5 </bdi><abbr title="Cyclic Redundancy Code">CRC</abbr> algorithm</a></li><li class="tocline"><a class="tocxref" href="#5ChunkOrdering"><bdi class="secno">5.6 </bdi>Chunk ordering</a></li><li class="tocline"><a class="tocxref" href="#sec-defining-new-chunks"><bdi class="secno">5.7 </bdi>Defining chunks</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#sec-defining-public-chunks-general"><bdi class="secno">5.7.1 </bdi>General</a></li><li class="tocline"><a class="tocxref" href="#sec-defining-public-chunks"><bdi class="secno">5.7.2 </bdi>Defining public chunks</a></li><li class="tocline"><a class="tocxref" href="#sec-defining-private-chunks"><bdi class="secno">5.7.3 </bdi>Defining private chunks</a></li></ol></li><li class="tocline"><a class="tocxref" href="#sec-field-value-extensibility"><bdi class="secno">5.8 </bdi>Private field values</a></li></ol></li><li class="tocline"><a class="tocxref" href="#6Transformation"><bdi class="secno">6. </bdi>Reference image to PNG image transformation</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#6Colour-values"><bdi class="secno">6.1 </bdi>Color types and values</a></li><li class="tocline"><a class="tocxref" href="#6AlphaRepresentation"><bdi class="secno">6.2 </bdi>Alpha representation</a></li></ol></li><li class="tocline"><a class="tocxref" href="#7Transformation"><bdi class="secno">7. </bdi>Encoding the PNG image as a PNG datastream</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#7Integers-and-byte-order"><bdi class="secno">7.1 </bdi>Integers and byte order</a></li><li class="tocline"><a class="tocxref" href="#7Scanline"><bdi class="secno">7.2 </bdi>Scanlines</a></li><li class="tocline"><a class="tocxref" href="#7Filtering"><bdi class="secno">7.3 </bdi>Filtering</a></li></ol></li><li class="tocline"><a class="tocxref" href="#8Interlace"><bdi class="secno">8. </bdi>Interlacing and pass extraction</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#8InterlaceIntro">Introduction</a></li><li class="tocline"><a class="tocxref" href="#8InterlaceMethods"><bdi class="secno">8.1 </bdi>Interlace methods</a></li></ol></li><li class="tocline"><a class="tocxref" href="#9Filters"><bdi class="secno">9. </bdi>Filtering</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#9FtIntro"><bdi class="secno">9.1 </bdi>Filter methods and filter types</a></li><li class="tocline"><a class="tocxref" href="#9Filter-types"><bdi class="secno">9.2 </bdi>Filter types for filter method 0</a></li><li class="tocline"><a class="tocxref" href="#9Filter-type-3-Average"><bdi class="secno">9.3 </bdi>Filter type 3: Average</a></li><li class="tocline"><a class="tocxref" href="#9Filter-type-4-Paeth"><bdi class="secno">9.4 </bdi>Filter type 4: Paeth</a></li></ol></li><li class="tocline"><a class="tocxref" href="#10Compression"><bdi class="secno">10. </bdi>Compression</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#10CompressionCM0"><bdi class="secno">10.1 </bdi>Compression method 0</a></li><li class="tocline"><a class="tocxref" href="#10CompressionFSL"><bdi class="secno">10.2 </bdi>Compression of the sequence of filtered scanlines</a></li><li class="tocline"><a class="tocxref" href="#10CompressionOtherUses"><bdi class="secno">10.3 </bdi>Other uses of compression</a></li></ol></li><li class="tocline"><a class="tocxref" href="#11Chunks"><bdi class="secno">11. </bdi>Chunk specifications</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#11Introduction"><bdi class="secno">11.1 </bdi>General</a></li><li class="tocline"><a class="tocxref" href="#11Critical-chunks"><bdi class="secno">11.2 </bdi>Critical chunks</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#11CcGen">Introduction</a></li><li class="tocline"><a class="tocxref" href="#11IHDR"><bdi class="secno">11.2.1 </bdi><span class="chunk">IHDR</span> Image header</a></li><li class="tocline"><a class="tocxref" href="#11PLTE"><bdi class="secno">11.2.2 </bdi><span class="chunk">PLTE</span> Palette</a></li><li class="tocline"><a class="tocxref" href="#11IDAT"><bdi class="secno">11.2.3 </bdi><span class="chunk">IDAT</span> Image data</a></li><li class="tocline"><a class="tocxref" href="#11IEND"><bdi class="secno">11.2.4 </bdi><span class="chunk">IEND</span> Image trailer</a></li></ol></li><li class="tocline"><a class="tocxref" href="#11Ancillary-chunks"><bdi class="secno">11.3 </bdi>Ancillary chunks</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#11AcGen">Introduction</a></li><li class="tocline"><a class="tocxref" href="#11transinfo"><bdi class="secno">11.3.1 </bdi>Transparency information</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#11tRNS"><bdi class="secno">11.3.1.1 </bdi><span class="chunk">tRNS</span> Transparency</a></li></ol></li><li class="tocline"><a class="tocxref" href="#11addnlcolinfo"><bdi class="secno">11.3.2 </bdi>Color space information</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#11cHRM"><bdi class="secno">11.3.2.1 </bdi><span class="chunk">cHRM</span> Primary chromaticities and white point</a></li><li class="tocline"><a class="tocxref" href="#11gAMA"><bdi class="secno">11.3.2.2 </bdi><span class="chunk">gAMA</span> Image gamma</a></li><li class="tocline"><a class="tocxref" href="#11iCCP"><bdi class="secno">11.3.2.3 </bdi><span class="chunk">iCCP</span> Embedded ICC profile</a></li><li class="tocline"><a class="tocxref" href="#11sBIT"><bdi class="secno">11.3.2.4 </bdi><span class="chunk">sBIT</span> Significant bits</a></li><li class="tocline"><a class="tocxref" href="#srgb-standard-colour-space"><bdi class="secno">11.3.2.5 </bdi><span class="chunk">sRGB</span> Standard RGB color space</a></li><li class="tocline"><a class="tocxref" href="#cICP-chunk"><bdi class="secno">11.3.2.6 </bdi><span class="chunk">cICP</span> Coding-independent code points for video signal type identification</a></li><li class="tocline"><a class="tocxref" href="#mDCV-chunk"><bdi class="secno">11.3.2.7 </bdi><span class="chunk">mDCV</span> Mastering Display Color Volume</a></li><li class="tocline"><a class="tocxref" href="#cLLI-chunk"><bdi class="secno">11.3.2.8 </bdi><span class="chunk">cLLI</span> Content Light Level Information</a></li></ol></li><li class="tocline"><a class="tocxref" href="#11textinfo"><bdi class="secno">11.3.3 </bdi>Textual information</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#11textIntro">Introduction</a></li><li class="tocline"><a class="tocxref" href="#11keywords"><bdi class="secno">11.3.3.1 </bdi>Keywords and text strings</a></li><li class="tocline"><a class="tocxref" href="#11tEXt"><bdi class="secno">11.3.3.2 </bdi><span class="chunk">tEXt</span> Textual data</a></li><li class="tocline"><a class="tocxref" href="#11zTXt"><bdi class="secno">11.3.3.3 </bdi><span class="chunk">zTXt</span> Compressed textual data</a></li><li class="tocline"><a class="tocxref" href="#11iTXt"><bdi class="secno">11.3.3.4 </bdi><span class="chunk">iTXt</span> International textual data</a></li></ol></li><li class="tocline"><a class="tocxref" href="#11addnlsiinfo"><bdi class="secno">11.3.4 </bdi>Miscellaneous information</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#11bKGD"><bdi class="secno">11.3.4.1 </bdi><span class="chunk">bKGD</span> Background color</a></li><li class="tocline"><a class="tocxref" href="#11hIST"><bdi class="secno">11.3.4.2 </bdi><span class="chunk">hIST</span> Image histogram</a></li><li class="tocline"><a class="tocxref" href="#11pHYs"><bdi class="secno">11.3.4.3 </bdi><span class="chunk">pHYs</span> Physical pixel dimensions</a></li><li class="tocline"><a class="tocxref" href="#11sPLT"><bdi class="secno">11.3.4.4 </bdi><span class="chunk">sPLT</span> Suggested palette</a></li><li class="tocline"><a class="tocxref" href="#eXIf"><bdi class="secno">11.3.4.5 </bdi><span class="chunk">eXIf</span> Exchangeable Image File (Exif) Profile</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#exif-general-recommendations"><bdi class="secno">11.3.4.5.1 </bdi><span class="chunk">eXIf</span> General Recommendations</a></li><li class="tocline"><a class="tocxref" href="#exif-recommendations-for-decoders"><bdi class="secno">11.3.4.5.2 </bdi><span class="chunk">eXIf</span> Recommendations for Decoders</a></li><li class="tocline"><a class="tocxref" href="#exif-recommendations-for-encoders"><bdi class="secno">11.3.4.5.3 </bdi><span class="chunk">eXIf</span> Recommendations for Encoders</a></li></ol></li></ol></li><li class="tocline"><a class="tocxref" href="#11timestampinfo"><bdi class="secno">11.3.5 </bdi>Time stamp information</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#11tIME"><bdi class="secno">11.3.5.1 </bdi><span class="chunk">tIME</span> Image last-modification time</a></li></ol></li><li class="tocline"><a class="tocxref" href="#animation-information"><bdi class="secno">11.3.6 </bdi>Animation information</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#acTL-chunk"><bdi class="secno">11.3.6.1 </bdi><span class="chunk">acTL</span> Animation Control Chunk</a></li><li class="tocline"><a class="tocxref" href="#fcTL-chunk"><bdi class="secno">11.3.6.2 </bdi><span class="chunk">fcTL</span> Frame Control Chunk</a></li><li class="tocline"><a class="tocxref" href="#fdAT-chunk"><bdi class="secno">11.3.6.3 </bdi><span class="chunk">fdAT</span> Frame Data Chunk</a></li></ol></li></ol></li></ol></li><li class="tocline"><a class="tocxref" href="#12Encoders"><bdi class="secno">12. </bdi>PNG Encoders</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#12Introduction">Introduction</a></li><li class="tocline"><a class="tocxref" href="#12Encoder-gamma-handling"><bdi class="secno">12.1 </bdi>Encoder gamma handling</a></li><li class="tocline"><a class="tocxref" href="#12Encoder-colour-handling"><bdi class="secno">12.2 </bdi>Encoder color handling</a></li><li class="tocline"><a class="tocxref" href="#12Alpha-channel-creation"><bdi class="secno">12.3 </bdi>Alpha channel creation</a></li><li class="tocline"><a class="tocxref" href="#12Sample-depth-scaling"><bdi class="secno">12.4 </bdi>Sample depth scaling</a></li><li class="tocline"><a class="tocxref" href="#12Suggested-palettes"><bdi class="secno">12.5 </bdi>Suggested palettes</a></li><li class="tocline"><a class="tocxref" href="#12Interlacing"><bdi class="secno">12.6 </bdi>Interlacing</a></li><li class="tocline"><a class="tocxref" href="#12Filter-selection"><bdi class="secno">12.7 </bdi>Filter selection</a></li><li class="tocline"><a class="tocxref" href="#12Compression"><bdi class="secno">12.8 </bdi>Compression</a></li><li class="tocline"><a class="tocxref" href="#12Text-chunk-processing"><bdi class="secno">12.9 </bdi>Text chunk processing</a></li><li class="tocline"><a class="tocxref" href="#12Chunk-processing"><bdi class="secno">12.10 </bdi>Chunking</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#12Use-of-private-chunks"><bdi class="secno">12.10.1 </bdi>Use of private chunks</a></li><li class="tocline"><a class="tocxref" href="#12Private-type-and-method-codes"><bdi class="secno">12.10.2 </bdi>Use of non-reserved field values</a></li><li class="tocline"><a class="tocxref" href="#12Ancillary"><bdi class="secno">12.10.3 </bdi>Ancillary chunks</a></li></ol></li></ol></li><li class="tocline"><a class="tocxref" href="#13Decoders"><bdi class="secno">13. </bdi>PNG decoders and viewers</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#13Introduction">Introduction</a></li><li class="tocline"><a class="tocxref" href="#13Decoders.Errors"><bdi class="secno">13.1 </bdi>Error handling</a></li><li class="tocline"><a class="tocxref" href="#13Error-checking"><bdi class="secno">13.2 </bdi>Error checking</a></li><li class="tocline"><a class="tocxref" href="#13Security-considerations"><bdi class="secno">13.3 </bdi>Security considerations</a></li><li class="tocline"><a class="tocxref" href="#Privacy-considerations"><bdi class="secno">13.4 </bdi>Privacy considerations</a></li><li class="tocline"><a class="tocxref" href="#13Chunking"><bdi class="secno">13.5 </bdi>Chunking</a></li><li class="tocline"><a class="tocxref" href="#13Pixel-dimensions"><bdi class="secno">13.6 </bdi>Pixel dimensions</a></li><li class="tocline"><a class="tocxref" href="#13Text-chunk-processing"><bdi class="secno">13.7 </bdi>Text chunk processing</a></li><li class="tocline"><a class="tocxref" href="#13Decompression"><bdi class="secno">13.8 </bdi>Decompression</a></li><li class="tocline"><a class="tocxref" href="#13Filtering"><bdi class="secno">13.9 </bdi>Filtering</a></li><li class="tocline"><a class="tocxref" href="#13Progressive-display"><bdi class="secno">13.10 </bdi>Interlacing and progressive display</a></li><li class="tocline"><a class="tocxref" href="#13Truecolour-image-handling"><bdi class="secno">13.11 </bdi>Truecolor image handling</a></li><li class="tocline"><a class="tocxref" href="#13Sample-depth-rescaling"><bdi class="secno">13.12 </bdi>Sample depth rescaling</a></li><li class="tocline"><a class="tocxref" href="#13Decoder-gamma-handling"><bdi class="secno">13.13 </bdi>Decoder gamma handling</a></li><li class="tocline"><a class="tocxref" href="#13Decoder-colour-handling"><bdi class="secno">13.14 </bdi>Decoder color handling</a></li><li class="tocline"><a class="tocxref" href="#13Background-colour"><bdi class="secno">13.15 </bdi>Background color</a></li><li class="tocline"><a class="tocxref" href="#13Alpha-channel-processing"><bdi class="secno">13.16 </bdi>Alpha channel processing</a></li><li class="tocline"><a class="tocxref" href="#13Histogram-and-suggested-palette-usage"><bdi class="secno">13.17 </bdi>Histogram and suggested palette usage</a></li></ol></li><li class="tocline"><a class="tocxref" href="#14EditorsExt"><bdi class="secno">14. </bdi>Editors</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#14Additional-chunk-types"><bdi class="secno">14.1 </bdi>Additional chunk types</a></li><li class="tocline"><a class="tocxref" href="#14Ordering"><bdi class="secno">14.2 </bdi>Behavior of PNG editors</a></li><li class="tocline"><a class="tocxref" href="#14Ordering-of-chunks"><bdi class="secno">14.3 </bdi>Ordering of chunks</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#14Ordering-of-critical-chunks"><bdi class="secno">14.3.1 </bdi>Ordering of critical chunks</a></li><li class="tocline"><a class="tocxref" href="#14Ordering-of-ancillary-chunks"><bdi class="secno">14.3.2 </bdi>Ordering of ancillary chunks</a></li></ol></li></ol></li><li class="tocline"><a class="tocxref" href="#conformance"><bdi class="secno">15. </bdi>Conformance</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#conformance-0"><bdi class="secno">15.1 </bdi>Conformance</a></li><li class="tocline"><a class="tocxref" href="#15ConfIntro"><bdi class="secno">15.2 </bdi>Introduction</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#15ConfObjectives"><bdi class="secno">15.2.1 </bdi>Objectives</a></li><li class="tocline"><a class="tocxref" href="#15ConfScope"><bdi class="secno">15.2.2 </bdi>Scope</a></li></ol></li><li class="tocline"><a class="tocxref" href="#15ConformanceConf"><bdi class="secno">15.3 </bdi>Conformance conditions</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#15FileConformance"><bdi class="secno">15.3.1 </bdi>Conformance of PNG datastreams</a></li><li class="tocline"><a class="tocxref" href="#15ConformanceEncoder"><bdi class="secno">15.3.2 </bdi>Conformance of PNG encoders</a></li><li class="tocline"><a class="tocxref" href="#15ConformanceDecoder"><bdi class="secno">15.3.3 </bdi>Conformance of PNG decoders</a></li><li class="tocline"><a class="tocxref" href="#15ConformanceEditor"><bdi class="secno">15.3.4 </bdi>Conformance of PNG editors</a></li></ol></li></ol></li><li class="tocline"><a class="tocxref" href="#IANA-registrations"><bdi class="secno">A. </bdi>Internet Media Types</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#A-Media-type"><bdi class="secno">A.1 </bdi>image/png</a></li><li class="tocline"><a class="tocxref" href="#image-apng"><bdi class="secno">A.2 </bdi>image/apng</a></li></ol></li><li class="tocline"><a class="tocxref" href="#newchunks"><bdi class="secno">B. </bdi>Guidelines for private chunk types</a></li><li class="tocline"><a class="tocxref" href="#gammachromaticity"><bdi class="secno">C. </bdi>Gamma and chromaticity</a></li><li class="tocline"><a class="tocxref" href="#samplecrc"><bdi class="secno">D. </bdi>Sample <abbr title="Cyclic Redundancy Code">CRC</abbr> implementation</a></li><li class="tocline"><a class="tocxref" href="#onlineresources"><bdi class="secno">E. </bdi>Online resources</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#E-Intro">Introduction</a></li><li class="tocline"><a class="tocxref" href="#E-icc-profile-specs"><bdi class="secno">E.1 </bdi>ICC profile specifications</a></li><li class="tocline"><a class="tocxref" href="#E-PNG-home-page"><bdi class="secno">E.2 </bdi>PNG web site</a></li><li class="tocline"><a class="tocxref" href="#E-Sample-implementation"><bdi class="secno">E.3 </bdi>Sample implementation and test images</a></li></ol></li><li class="tocline"><a class="tocxref" href="#F-ChangeList"><bdi class="secno">F. </bdi>Changes</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#changes-20250121/"><bdi class="secno">F.1 </bdi>Changes since the <span class="formerLink">Candidate Recommendation Draft of 21 January 2025 (Third Edition)</span></a></li><li class="tocline"><a class="tocxref" href="#changes-20240718"><bdi class="secno">F.2 </bdi>Changes since the <span class="formerLink">Candidate Recommendation Draft of 18 July 2024 (Third Edition)</span></a></li><li class="tocline"><a class="tocxref" href="#changes-20230921"><bdi class="secno">F.3 </bdi>Changes since the <span class="formerLink">Candidate Recommendation Snapshot of 21 September 2023 (Third Edition)</span></a></li><li class="tocline"><a class="tocxref" href="#changes-20230720"><bdi class="secno">F.4 </bdi>Changes since the <span class="formerLink"> Working Draft of 20 July 2023 (Third Edition)</span></a></li><li class="tocline"><a class="tocxref" href="#changes-20221025"><bdi class="secno">F.5 </bdi>Changes since the <span class="formerLink"> First Public Working Draft of 25 October 2022 (Third Edition)</span></a></li><li class="tocline"><a class="tocxref" href="#changes-20031110"><bdi class="secno">F.6 </bdi>Changes since the <span class="formerLink"><abbr title="World Wide Web Consortium">W3C</abbr> Recommendation of 10 November 2003</span> (PNG Second Edition)</a></li><li class="tocline"><a class="tocxref" href="#changes-between-first-and-second-editions"><bdi class="secno">F.7 </bdi>Changes between First and Second Editions</a></li></ol></li><li class="tocline"><a class="tocxref" href="#references"><bdi class="secno">G. </bdi>References</a><ol class="toc"><li class="tocline"><a class="tocxref" href="#normative-references"><bdi class="secno">G.1 </bdi>Normative references</a></li><li class="tocline"><a class="tocxref" href="#informative-references"><bdi class="secno">G.2 </bdi>Informative references</a></li></ol></li></ol></nav> <section id="introduction"><div class="header-wrapper"><h2 id="Introduction"><bdi class="secno">1. </bdi>Introduction</h2><a class="self-link" href="#Introduction" aria-label="Permalink for Section 1."></a></div> <p>The design goals for this specification were:</p> <ol> <li>Portability: encoding, decoding, and transmission should be software and hardware platform independent.</li> <li>Completeness: it should be possible to represent <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-2">truecolor</a>, <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-2">indexed-color</a>, and <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-2">greyscale</a> images, in each case with the option of transparency, color space information, and ancillary information such as textual comments. </li> <li>Serial encode and decode: it should be possible for datastreams to be generated serially and read serially, allowing the datastream format to be used for on-the-fly generation and display of images across a serial communication channel.</li> <li>Progressive presentation: it should be possible to transmit datastreams so that an approximation of the whole image can be presented initially, and progressively enhanced as the datastream is received.</li> <li>Robustness to transmission errors: it should be possible to detect datastream transmission errors reliably.</li> <li>Losslessness: filtering and compression should preserve all information.</li> <li>Performance: any filtering, compression, and progressive image presentation should be aimed at efficient decoding and presentation. Fast encoding is a less important goal than fast decoding. Decoding speed may be achieved at the expense of encoding speed.</li> <li>Compression: images should be compressed effectively, consistent with the other design goals.</li> <li>Simplicity: developers should be able to implement the standard easily.</li> <li>Interchangeability: any standard-conforming PNG decoder shall be capable of reading all conforming PNG datastreams.</li> <li>Flexibility: future extensions and private additions should be allowed for without compromising the interchangeability of standard PNG datastreams.</li> <li>Freedom from legal restrictions: no algorithms should be used that are not freely available.</li> </ol> </section><section id="scope"><div class="header-wrapper"><h2 id="1Scope"><bdi class="secno">2. </bdi>Scope</h2><a class="self-link" href="#1Scope" aria-label="Permalink for Section 2."></a></div> <p>This specification specifies a datastream and an associated file format, Portable Network Graphics (PNG, pronounced "ping"), for a <a href="#dfn-lossless" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-lossless-2">lossless</a>, portable, compressed individual computer graphics image or frame-based animation, transmitted across the Internet. </p></section> <section id="terms-definitions-and-abbreviated-terms"><div class="header-wrapper"><h2 id="3Defsandabbrevs"><bdi class="secno">3. </bdi>Terms, definitions, and abbreviated terms</h2><a class="self-link" href="#3Defsandabbrevs" aria-label="Permalink for Section 3."></a></div> <p>For the purposes of this specification the following definitions apply.</p> <dl> <dt id="3byte"><dfn data-plurals="bytes" id="dfn-byte" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">byte</dfn> </dt> <dt>octet</dt> <dd>8-bit binary integer in the range [0, 255] where the most significant bit is bit 7 and the least significant bit is bit 0.</dd> <dt id="3byteOrder"><dfn id="dfn-byte-order" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">byte order</dfn> </dt> <dd> ordering of <a href="#dfn-byte" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-byte-1">bytes</a> for multi-byte data values. </dd> <dt id="3chromaticity"><dfn id="dfn-chromaticity" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">chromaticity</dfn> </dt> <dd>pair of <i>x</i> and <i>y</i> values in the <i>xyY</i> space specified at [<cite><a class="bibref" data-link-type="biblio" href="#bib-colorimetry" title="Colorimetry, Fourth Edition. CIE 015:2018">COLORIMETRY</a></cite>]. <div class="note" role="note" id="issue-container-generatedID"><div role="heading" class="note-title marker" id="h-note" aria-level="3"><span>Note</span></div><p class="">Chromaticity is a measure of the quality of a color regardless of its luminance.</p></div></dd> <dt id="3composite"><dfn data-lt="composited|composite|composite (verb)" id="dfn-composited" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">composite (verb)</dfn> </dt> <dd>form an image by merging a foreground image and a background image, using transparency information to determine where and to what extent the background should be visible. <div class="note" role="note" id="issue-container-generatedID-0"><div role="heading" class="note-title marker" id="h-note-0" aria-level="3"><span>Note</span></div><p class="">The foreground image is said to be <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-1">composited</a> against the background.</p></div> </dd> <dt id="3datastream"><dfn id="dfn-datastream" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">datastream</dfn> </dt> <dd> sequence of <a href="#dfn-byte" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-byte-2">bytes</a>. </dd> <dt id="3deflate"><dfn id="dfn-deflate" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">deflate</dfn> </dt> <dd> member of the <a href="#3LZ77" class="internalDFN" data-link-type="dfn" id="ref-for-3LZ77-1">LZ77</a> family of compression methods. <p>SOURCE: [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc1951" title="DEFLATE Compressed Data Format Specification version 1.3">RFC1951</a></cite>]</p> </dd> <dt><dfn id="dfn-frame" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">frame</dfn></dt> <dd>For static PNG, the <a href="#dfn-static-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-static-image-1">static image</a> is considered to be the first (and only) frame. For animated PNG, each image that forms part of the <a href="#apng-frame-based-animation">frame-based animation</a> sequence is a frame. Thus, for animated PNG, when the static image is not the first frame, the static image is not considered to be a frame. </dd> <dt id="3frameBuffer"><dfn data-plurals="frame buffers" id="dfn-frame-buffer" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">frame buffer</dfn> </dt> <dd> the final digital storage area for the image shown by most types of computer display. <div class="note" role="note" id="issue-container-generatedID-1"><div role="heading" class="note-title marker" id="h-note-1" aria-level="3"><span>Note</span></div><p class="">Software causes an image to appear on screen by loading the image into the <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-1">frame buffer</a>.</p></div> </dd> <dt><dfn id="dfn-fully-transparent-black" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">fully transparent black</dfn> </dt> <dd>pixel where the red, green, blue and alpha components are all equal to zero.</dd> <dt><dfn data-plurals="gamma values" id="dfn-gamma-value" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">gamma value</dfn> </dt> <dd> value of the exponent of a <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-1">gamma</a> <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-1">transfer function</a>. </dd> <dt id="3gamma"><dfn id="dfn-gamma" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">gamma</dfn> </dt> <dd> power-law <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-2">transfer function</a>. </dd> <dt>high dynamic range (<dfn id="dfn-hdr" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">HDR</dfn>) </dt> <dd> an image format capable of storing images with a relatively high dynamic range similar to or in excess of the human visual system's instantaneous dynamic range (~12-14 <a href="#dfn-stop" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-stop-1">stops</a>). PNG allows the use of two <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-1">HDR</a> formats, <a href="#dfn-hlg" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hlg-1">HLG</a> and <a href="#dfn-pq" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-pq-1">PQ</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>]. </dd> <dt>hybrid log-gamma (<dfn id="dfn-hlg" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">HLG</dfn>) </dt> <dd> <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-3">transfer function</a> defined in [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] Table 5. (A relative scene-referred system.) </dd> <dt><dfn data-plurals="full-range images" id="dfn-full-range-image" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">full-range image</dfn> </dt> <dd>image where reference black and white correspond, respectively, to sample values <code>0</code> and <code>2<sup>bit depth</sup> - 1</code>.</dd> <dt id="3imageData"><dfn id="dfn-image-data" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">image data</dfn> </dt> <dd> 1-dimensional array of <a href="#dfn-scanline" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-scanline-1">scanlines</a> within an image. </dd> <dt id="3interlacedPNGimage"><dfn id="dfn-interlaced-png-image" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">interlaced PNG image</dfn> </dt> <dd> sequence of <a href="#3reducedImage" class="internalDFN" data-link-type="dfn" id="ref-for-3reducedImage-1">reduced images</a> generated from the <a href="#3PNGimage" class="internalDFN" data-link-type="dfn" id="ref-for-3PNGimage-1">PNG image</a> by <a href="#3passExtraction" class="internalDFN" data-link-type="dfn" id="ref-for-3passExtraction-1">pass extraction</a>. </dd> <dt id="3losslessCompression"><dfn id="dfn-lossless" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">lossless</dfn> </dt> <dd>method of data compression that permits reconstruction of the original data exactly, bit-for-bit.</dd> <dt id="3luminance"><dfn id="dfn-luminance" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">luminance</dfn> </dt> <dd> an objective measurement of the visible light intensity, taking into account the sensitivity of the human eye to different wavelengths. <div class="note" role="note" id="issue-container-generatedID-2"><div role="heading" class="note-title marker" id="h-note-2" aria-level="3"><span>Note</span></div><p class="">Luminance and <a href="#dfn-chromaticity" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-chromaticity-1">chromaticity</a> together fully define a measured color. See <a href="https://colorusage.arc.nasa.gov/lum_and_chrom.php">Luminance and Chromaticity</a> or, for a formal definition [<cite><a class="bibref" data-link-type="biblio" href="#bib-colorimetry" title="Colorimetry, Fourth Edition. CIE 015:2018">COLORIMETRY</a></cite>].</p></div> </dd> <dt><dfn id="3LZ77" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">LZ77</dfn> </dt> <dd>data compression algorithm described in [<cite><a class="bibref" data-link-type="biblio" href="#bib-ziv-lempel" title="A Universal Algorithm for Sequential Data Compression, IEEE Transactions on Information Theory, vol. IT-23, no. 3, pp. 337 - 343">Ziv-Lempel</a></cite>].</dd> <dt><dfn data-plurals="narrow-range images" id="dfn-narrow-range-image" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">narrow-range image</dfn> </dt> <dd>Image where reference black and white do not correspond, respectively, to sample values <code>0</code> and <code>2<sup>bit depth</sup> - 1</code>.</dd> <dt id="3networkByteOrder"><dfn id="dfn-network-byte-order" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">network byte order</dfn> </dt> <dd> <a href="#dfn-byte-order" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-byte-order-1">byte order</a> in which the most significant byte comes first, then the less significant bytes in descending order of significance (<abbr title="Most Significant Byte">MSB</abbr> <abbr title="Least Significant Byte">LSB</abbr> for two-byte integers, <abbr title="Most Significant Byte">MSB</abbr> B2 B1 <abbr title="Least Significant Byte">LSB</abbr> for four-byte integers). </dd> <dt>perceptual quantizer (<dfn id="dfn-pq" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">PQ</dfn>) </dt> <dd> <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-4">transfer function</a> defined in [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] Table 4. (An absolute display-referred system.) <div class="note" role="note" id="issue-container-generatedID-3"><div role="heading" class="note-title marker" id="h-note-3" aria-level="3"><span>Note</span></div><p class=""> Only RGB may be used in PNG, ICtCp is NOT supported. </p></div> </dd> <dt id="3PNGdecoder">PNG decoder</dt> <dd> process or device that reconstructs the <a href="#3referenceImage" class="internalDFN" data-link-type="dfn" id="ref-for-3referenceImage-1">reference image</a> from a <a href="#3PNGdatastream" class="internalDFN" data-link-type="dfn" id="ref-for-3PNGdatastream-1">PNG datastream</a> and generates a corresponding <a href="#3deliveredImage" class="internalDFN" data-link-type="dfn" id="ref-for-3deliveredImage-1">delivered image</a>. </dd> <dt id="3PNGeditor"><dfn data-plurals="png editors" id="dfn-png-editor" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">PNG editor</dfn> </dt> <dd> process or device that creates a modification of an existing <a href="#3PNGdatastream" class="internalDFN" data-link-type="dfn" id="ref-for-3PNGdatastream-2">PNG datastream</a>, preserving unmodified ancillary information wherever possible, and obeying the <a href="#3chunk" class="internalDFN" data-link-type="dfn" id="ref-for-3chunk-1">chunk</a> ordering rules, even for unknown chunk types. </dd> <dt id="3PNGencoder">PNG encoder </dt> <dd> process or device which constructs a <a href="#3referenceImage" class="internalDFN" data-link-type="dfn" id="ref-for-3referenceImage-2">reference image</a> from a <a href="#3sourceImage" class="internalDFN" data-link-type="dfn" id="ref-for-3sourceImage-1">source image</a>, and generates a <a href="#3PNGdatastream" class="internalDFN" data-link-type="dfn" id="ref-for-3PNGdatastream-3">PNG datastream</a> representing the reference image. </dd> <dt id="3PNGfile">PNG file </dt> <dd> <a href="#3PNGdatastream" class="internalDFN" data-link-type="dfn" id="ref-for-3PNGdatastream-4">PNG datastream</a> stored as a file. </dd> <dt id="3PNGfourByteUnSignedInteger"><dfn data-plurals="png four-byte unsigned integers" id="dfn-png-four-byte-unsigned-integer" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">PNG four-byte unsigned integer</dfn> </dt> <dd> <p>a four-byte unsigned integer limited to the range 0 to 2<sup>31</sup>-1.</p> <div class="note" role="note" id="issue-container-generatedID-4"><div role="heading" class="note-title marker" id="h-note-4" aria-level="3"><span>Note</span></div><p class="">The restriction is imposed in order to accommodate languages that have difficulty with unsigned four-byte values.</p></div> </dd> <dt id="3PNGtwoByteUnSignedInteger"><dfn id="dfn-png-two-byte-unsigned-integer" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">PNG two-byte unsigned integer</dfn> </dt> <dd> <p>a two-byte unsigned integer in network byte order.</p> </dd> <dt id="3sample"><dfn data-plurals="samples" id="dfn-sample" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">sample</dfn> </dt> <dd> intersection of a <a href="#3channel" class="internalDFN" data-link-type="dfn" id="ref-for-3channel-1">channel</a> and a <a href="#3pixel" class="internalDFN" data-link-type="dfn" id="ref-for-3pixel-1">pixel</a> in an image. </dd> <dt id="3sampleDepth">sample depth</dt> <dd> number of bits used to represent a <a href="#dfn-sample" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sample-1">sample</a> value. </dd> <dt id="3scanline"><dfn data-plurals="scanlines" id="dfn-scanline" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">scanline</dfn> </dt> <dd> row of <a href="#3pixel" class="internalDFN" data-link-type="dfn" id="ref-for-3pixel-2">pixels</a> within an image or <a href="#dfn-interlaced-png-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-interlaced-png-image-1">interlaced PNG image</a>. </dd> <dt>standard dynamic range (<dfn id="dfn-sdr" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">SDR</dfn>) </dt> <dd> an image format capable of storing images with a relatively low dynamic range of 5-8 <a href="#dfn-stop" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-stop-2">stops</a>. Examples include [<cite><a class="bibref" data-link-type="biblio" href="#bib-srgb" title="Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB">SRGB</a></cite>], [<cite><a class="bibref" data-link-type="biblio" href="#bib-display-p3" title="Display P3">Display-P3</a></cite>], [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.709" title="ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange">ITU-R-BT.709</a></cite>]. <div class="note" role="note" id="issue-container-generatedID-5"><div role="heading" class="note-title marker" id="h-note-5" aria-level="3"><span>Note</span></div><p class="">Standard dynamic range is independent of the primaries and hence, gamut. Wide color gamut <a href="#dfn-sdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sdr-1">SDR</a> formats are supported by PNG.</p></div></dd> <dt><dfn data-plurals="stops" id="dfn-stop" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">stop</dfn> </dt> <dd> a change in scene light luminance of a factor of 2. </dd> <dt><dfn data-plurals="transfer functions" id="dfn-transfer-function" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">transfer function</dfn> </dt> <dd>function relating image luminance with image samples.</dd> <dt id="3whitePoint"><dfn data-plurals="white points" id="dfn-white-point" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">white point</dfn> </dt> <dd> <a href="#dfn-chromaticity" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-chromaticity-2">chromaticity</a> of a computer display's nominal white value. </dd> <dt id="3zlib"><dfn id="dfn-zlib" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">zlib</dfn> </dt> <dd> <p><a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-1">deflate</a>-style compression method.</p> <p>SOURCE: [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc1950" title="ZLIB Compressed Data Format Specification version 3.3">rfc1950</a></cite>]</p> <div class="note" role="note" id="issue-container-generatedID-6"><div role="heading" class="note-title marker" id="h-note-6" aria-level="3"><span>Note</span></div><p class="">Also refers to the name of a library containing a sample implementation of this method.</p></div> </dd> <dt id="3CRC">Cyclic Redundancy Code</dt> <dt><abbr title="Cyclic Redundancy Code">CRC</abbr></dt> <dd> <p>type of check value designed to detect most transmission errors.</p> <div class="note" role="note" id="issue-container-generatedID-7"><div role="heading" class="note-title marker" id="h-note-7" aria-level="3"><span>Note</span></div><p class="">A decoder calculates the <abbr title="Cyclic Redundancy Code">CRC</abbr> for the received data and checks by comparing it to the <abbr title="Cyclic Redundancy Code">CRC</abbr> calculated by the encoder and appended to the data. A mismatch indicates that the data or the <abbr title="Cyclic Redundancy Code">CRC</abbr> were corrupted in transit.</p></div> </dd> <dt id="3CRT">Cathode Ray Tube</dt> <dt><abbr title="Cathode Ray Tube">CRT</abbr></dt> <dd>vacuum tube containing one or more electron guns, which emit electron beams that are manipulated to display images on a phosphorescent screen.</dd> <dt>Electro-Optical Transfer Function</dt> <dt> <abbr title="Electro-Optical Transfer Function"><dfn id="dfn-eotf" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn"><abbr title="Electro-Optical Transfer Function">EOTF</abbr></dfn></abbr> </dt> <dd>The <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-5">transfer function</a> between the electrical or digital domain and light energy. It defines the amount of light emitted by a display for a given input signal.</dd> <dt id="3LSB">Least Significant Byte</dt> <dt><abbr title="Least Significant Byte">LSB</abbr></dt> <dd> Least significant byte of a multi-<a href="#dfn-byte" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-byte-3">byte</a> value. </dd> <dt id="3MSB">Most Significant Byte</dt> <dt><abbr title="Most Significant Byte">MSB</abbr></dt> <dd> Most significant byte of a multi-<a href="#dfn-byte" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-byte-4">byte</a> value. </dd> <dt>Opto-Electrical Transfer Function</dt> <dt> <abbr title="Opto-Electrical Transfer Function"><dfn id="dfn-oetf" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn"><abbr title="Opto-Electrical Transfer Function">OETF</abbr></dfn></abbr> </dt> <dd>The <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-6">transfer function</a> between light energy and the electrical or digital domain. It defines the amount of light in a scene required to produce a given output signal.</dd> </dl> </section> <section id="concepts"><div class="header-wrapper"><h2 id="4Concepts"><bdi class="secno">4. </bdi>Concepts</h2><a class="self-link" href="#4Concepts" aria-label="Permalink for Section 4."></a></div> <section id="static-and-animated-images"><div class="header-wrapper"><h3 id="x4-1-static-and-animated-images"><bdi class="secno">4.1 </bdi>Static and Animated images</h3><a class="self-link" href="#static-and-animated-images" aria-label="Permalink for Section 4.1"></a></div> <p>All PNG images contain a single <dfn id="dfn-static-image" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">static image</dfn>.</p> <p>Some PNG images — called <dfn class="lint-ignore" id="dfn-animated-png" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Animated PNG</dfn> (<abbr title="Animated PNG">APNG</abbr>) — also contain a frame-based animation sequence, the <dfn id="dfn-animated-image" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">animated image</dfn>. The first frame of this may be — but need not be — the <a href="#dfn-static-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-static-image-2">static image</a>. Non-animation-capable displays (such as printers) will display the <a href="#dfn-static-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-static-image-3">static image</a> rather than the animation sequence.</p> <p>The <a href="#dfn-static-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-static-image-4">static image</a>, and each individual frame of an <a href="#dfn-animated-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-animated-image-1">animated image</a>, corresponds to a <em>reference image</em> and is stored as a <em>PNG image</em>.</p> </section> <section id="images"><div class="header-wrapper"><h3 id="4Concepts.Sourceimage"><bdi class="secno">4.2 </bdi>Images</h3><a class="self-link" href="#4Concepts.Sourceimage" aria-label="Permalink for Section 4.2"></a></div> <p>This specification specifies the PNG datastream, and places some requirements on PNG encoders, which generate PNG datastreams, PNG decoders, which interpret PNG datastreams, and <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-1">PNG editors</a>, which transform one PNG datastream into another. It does not specify the interface between an application and either a PNG encoder, decoder, or editor. The precise form in which an image is presented to an encoder or delivered by a decoder is not specified. Four kinds of image are distinguished.</p> <dl> <dt><dfn id="3sourceImage" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Source image</dfn></dt> <dd>The <i>source image</i> is the image presented to a PNG encoder.</dd> <dt><dfn id="3referenceImage" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Reference image</dfn></dt> <dd>The <a href="#3referenceImage" class="internalDFN" data-link-type="dfn" id="ref-for-3referenceImage-3">reference image</a>, which only exists conceptually, is a rectangular array of rectangular <dfn id="3pixel" data-plurals="pixel" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">pixels</dfn>, all having the same width and height, and all containing the same number of unsigned integer samples, either three (red, green, blue) or four (red, green, blue, alpha). The array of all samples of a particular kind (red, green, blue, or alpha) is called a <dfn id="3channel" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">channel</dfn>. Each channel has a sample depth in the range 1 to 16, which is the number of bits used by every sample in the channel. Different channels may have different sample depths. The red, green, and blue samples determine the intensities of the red, green, and blue components of the pixel's color; if they are all zero, the pixel is black, and if they all have their maximum values (2<sup>sampledepth</sup>-1), the pixel is white. The <dfn id="3alpha" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">alpha</dfn> sample determines a pixel's degree of opacity, where zero means fully transparent and the maximum value means fully opaque. In a three-channel reference image all pixels are fully opaque. (It is also possible for a four-channel reference image to have all pixels fully opaque; the difference is that the latter has a specific alpha sample depth, whereas the former does not.) Each horizontal row of pixels is called a scanline. Pixels are ordered from left to right within each scanline, and scanlines are ordered from top to bottom. Every reference image can be represented exactly by a <a href="#3PNGdatastream" class="internalDFN" data-link-type="dfn" id="ref-for-3PNGdatastream-5">PNG datastream</a> and every <a href="#3PNGdatastream" class="internalDFN" data-link-type="dfn" id="ref-for-3PNGdatastream-6">PNG datastream</a> can be converted into a reference image. A PNG encoder may transform the source image directly into a PNG image, but conceptually it first transforms the source image into a reference image, then transforms the reference image into a PNG image. Depending on the type of source image, the transformation from the source image to a reference image may require the loss of information. That transformation is beyond the scope of this International Standard. The reference image, however, can always be recovered exactly from a PNG datastream.</dd> <dt><dfn id="3PNGimage" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">PNG image</dfn></dt> <dd>The <i>PNG image</i> is obtained from the reference image by a series of transformations: <a href="#3alphaSeparation" class="internalDFN" data-link-type="dfn" id="ref-for-3alphaSeparation-1">alpha separation</a>, <a href="#3indexing" class="internalDFN" data-link-type="dfn" id="ref-for-3indexing-1">indexing</a>, <a href="#3RGBmerging" class="internalDFN" data-link-type="dfn" id="ref-for-3RGBmerging-1">RGB merging</a>, <a href="#3alphaCompaction" class="internalDFN" data-link-type="dfn" id="ref-for-3alphaCompaction-1">alpha compaction</a>, and <a href="#3sampleDepthScaling" class="internalDFN" data-link-type="dfn" id="ref-for-3sampleDepthScaling-1">sample depth scaling</a>. Five types of PNG image are defined (see <a href="#6Colour-values" class="sec-ref"><bdi class="secno">6.1 </bdi>Color types and values</a>). (If the PNG encoder actually transforms the source image directly into the PNG image, and the source image format is already similar to the PNG image format, the encoder may be able to avoid doing some of these transformations.) Although not all sample depths in the range 1 to 16 bits are explicitly supported in the PNG image, the number of significant bits in each channel of the reference image may be recorded. All channels in the PNG image have the same sample depth. A PNG encoder generates a PNG datastream from the PNG image. A PNG decoder takes the PNG datastream and recreates the PNG image. </dd> <dt><dfn id="3deliveredImage" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Delivered image</dfn></dt> <dd>The <a href="#3deliveredImage" class="internalDFN" data-link-type="dfn" id="ref-for-3deliveredImage-2">delivered image</a> is constructed from the PNG image obtained by decoding a PNG datastream. No specific format is specified for the <a href="#3deliveredImage" class="internalDFN" data-link-type="dfn" id="ref-for-3deliveredImage-3">delivered image</a>. A viewer presents an image to the user as close to the appearance of the original source image as it can achieve. </dd> </dl> <p>The relationships between the four kinds of image are illustrated in <a href="#image-relationship" class="fig-ref" title="Relationships between source, reference, PNG, and display images">Figure <bdi class="">1</bdi></a>.</p> <figure id="image-relationship"> <object id="figure41" data="figures/image-relationships.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#image-relationship">Figure <bdi class="figno">1</bdi></a> <span class="fig-title"> Relationships between source, reference, PNG, and display images </span></figcaption> </figure> <p>The relationships between samples, channels, pixels, and sample depth are illustrated in <a href="#sample-pixel-channel-relationship" class="fig-ref" title="Relationships between sample, sample depth, pixel, and channel">Figure <bdi class="">2</bdi></a>.</p> <figure id="sample-pixel-channel-relationship"> <object id="figure42" data="figures/sample-pixel-channel-relationship.svg" type="image/svg+xml" width="640" height="290"> </object> <figcaption><a class="self-link" href="#sample-pixel-channel-relationship">Figure <bdi class="figno">2</bdi></a> <span class="fig-title"> Relationships between sample, sample depth, pixel, and channel </span></figcaption> </figure> </section> <section id="4Concepts.ColourSpaces"><div class="header-wrapper"><h3 id="x4-3-color-spaces"><bdi class="secno">4.3 </bdi>Color spaces</h3><a class="self-link" href="#4Concepts.ColourSpaces" aria-label="Permalink for Section 4.3"></a></div> <p>The RGB color space in which color samples are situated may be specified in one of four ways:</p> <ol> <li>by CICP image format signaling metadata;</li> <li>by an ICC profile;</li> <li>by specifying explicitly that the color space is sRGB when the samples conform to this color space;</li> <li>by specifying a <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-1">gamma value</a> and the 1931 CIE <i>x,y</i> chromaticities of the red, green, and blue primaries used in the image and the reference <a href="#dfn-white-point" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-white-point-1">white point</a>. </li> </ol> <p>For high-end applications the first two methods provides the most flexibility and control. The third method enables one particular, but extremely common, color space to be indicated. The fourth method, which was standardized before ICC profiles were widely adopted, enables the exact chromaticities of the RGB data to be specified, along with the <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-2">gamma</a> correction to be applied (see <a href="#C-GammaAppendix" class="sec-ref"><bdi class="secno">C. </bdi>Gamma and chromaticity</a>). However, color-aware applications will prefer one of the first three methods, while color-unaware applications will typically ignore all four methods.</p> <p><a href="#color-chunk-precendence" class="table-ref" title="Color Chunk Priority">Table <bdi class="">1</bdi></a> is a list of chunk types that provide color space information, each with an associated Priority number. If a single image contains more than one of these chunk types, the chunk with the lowest Priority number should take precedence and any higher-numbered chunk types should be ignored.</p> <table id="color-chunk-precendence" class="numbered simple"> <caption><a class="self-link" href="#color-chunk-precendence">Table <bdi class="tableno">1</bdi></a> <span class="table-title"> Color Chunk Priority </span></caption> <tbody><tr> <th>Chunk Type</th> <th>Priority</th> </tr> <tr> <td><a href="#cICP-chunk" class="chunk">cICP</a></td> <td>1</td> </tr> <tr> <td><a class="chunk" href="#11iCCP">iCCP</a></td> <td>2</td> </tr> <tr> <td><a class="chunk" href="#11sRGB">sRGB</a></td> <td>3</td> </tr> <tr> <td><a class="chunk" href="#11cHRM">cHRM</a> and <a class="chunk" href="#11gAMA">gAMA</a></td> <td>4</td> </tr> </tbody></table> <p><a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-3">Gamma</a> correction is not applied to the alpha channel, if present. Alpha samples are always full-range and represent a linear fraction of full opacity.</p> <p>Mastering metadata may also be provided.</p> </section> <section id="4Concepts.PNGImageTransformation"><div class="header-wrapper"><h3 id="x4-4-reference-image-to-png-image-transformation"><bdi class="secno">4.4 </bdi>Reference image to PNG image transformation</h3><a class="self-link" href="#4Concepts.PNGImageTransformation" aria-label="Permalink for Section 4.4"></a></div> <section class="introductory" id="4Concepts.Introduction"><div class="header-wrapper"><h3 id="introduction-1">Introduction</h3><a class="self-link" href="#4Concepts.Introduction" aria-label="Permalink for this Section"></a></div> <p>A number of transformations are applied to the reference image to create the PNG image to be encoded (see <a href="#reference-to-png-transformation" class="fig-ref" title="Reference image to PNG image transformation">Figure <bdi class="">3</bdi></a>). The transformations are applied in the following sequence, where square brackets mean the transformation is optional:</p> <pre aria-busy="false"><code class="hljs css"><span class="hljs-selector-attr">[alpha separation]</span> indexing or ( <span class="hljs-selector-attr">[RGB merging]</span> <span class="hljs-selector-attr">[alpha compaction]</span> ) sample depth scaling</code></pre> <p>When every pixel is either fully transparent or fully opaque, the <a href="#3alphaSeparation" class="internalDFN" data-link-type="dfn" id="ref-for-3alphaSeparation-2">alpha separation</a>, <a href="#3alphaCompaction" class="internalDFN" data-link-type="dfn" id="ref-for-3alphaCompaction-2">alpha compaction</a>, and <a href="#3indexing" class="internalDFN" data-link-type="dfn" id="ref-for-3indexing-2">indexing</a> transformations can cause the recovered reference image to have an alpha sample depth different from the original reference image, or to have no alpha channel. This has no effect on the degree of opacity of any pixel. The two reference images are considered equivalent, and the transformations are considered lossless. Encoders that nevertheless wish to preserve the alpha sample depth may elect not to perform transformations that would alter the alpha sample depth.</p> <figure id="reference-to-png-transformation"> <object id="figure43" data="figures/reference-to-png-transformation.svg" type="image/svg+xml" height="525" width="370"> </object> <figcaption><a class="self-link" href="#reference-to-png-transformation">Figure <bdi class="figno">3</bdi></a> <span class="fig-title"> Reference image to PNG image transformation </span></figcaption> </figure> </section> <section id="4Concepts.Implied-alpha"><div class="header-wrapper"><h4 id="x4-4-1-alpha-separation"><bdi class="secno">4.4.1 </bdi><dfn id="3alphaSeparation" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Alpha separation</dfn></h4><a class="self-link" href="#4Concepts.Implied-alpha" aria-label="Permalink for Section 4.4.1"></a></div> <p>If all alpha samples in a reference image have the maximum value, then the alpha channel may be omitted, resulting in an equivalent image that can be encoded more compactly.</p> </section> <section id="4Concepts.Indexing"><div class="header-wrapper"><h4 id="x4-4-2-indexing"><bdi class="secno">4.4.2 </bdi>Indexing</h4><a class="self-link" href="#4Concepts.Indexing" aria-label="Permalink for Section 4.4.2"></a></div> <p>If the number of distinct pixel values is 256 or less, and the RGB sample depths are not greater than 8, and the alpha channel is absent or exactly 8 bits deep or every pixel is either fully transparent or fully opaque, then the alternative <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-3">indexed-color</a> representation, achieved through an <dfn id="3indexing" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">indexing</dfn> transformation, may be more efficient for encoding. In the <dfn id="3indexedColour" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">indexed-color</dfn> representation, each pixel is replaced by an index into a palette. The <dfn id="3palette" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">palette</dfn> is a list of entries each containing three 8-bit samples (red, green, blue). If an alpha channel is present, there is also a parallel table of 8-bit alpha samples, called the <dfn id="3alphaTable" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">alpha table</dfn>.</p> <figure id="indexed-colour-image"> <object id="figure44" height="450" width="660" data="figures/indexed-colour-image.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#indexed-colour-image">Figure <bdi class="figno">4</bdi></a> <span class="fig-title"> Indexed-color image </span></figcaption> </figure> <p>A suggested palette or palettes may be constructed even when the PNG image is not <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-4">indexed-color</a> in order to assist viewers that are capable of displaying only a limited number of colors.</p> <p>For <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-5">indexed-color</a> images, encoders can rearrange the palette so that the table entries with the maximum alpha value are grouped at the end. In this case the table can be encoded in a shortened form that does not include these entries.</p> <p>Encoders creating indexed-color PNG must not insert index values greater than the actual length of the palette table; to do so is an error, and decoders will vary in their handling of this error.</p> </section> <section id="4Concepts.RGBMerging"><div class="header-wrapper"><h4 id="x4-4-3-rgb-merging"><bdi class="secno">4.4.3 </bdi><dfn id="3RGBmerging" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">RGB merging</dfn> </h4><a class="self-link" href="#4Concepts.RGBMerging" aria-label="Permalink for Section 4.4.3"></a></div> <p>If the red, green, and blue channels have the same sample depth, and, for each pixel, the values of the red, green, and blue samples are equal, then these three channels may be merged into a single greyscale channel.</p> </section> <section id="4Concepts.Alpha-indexing"><div class="header-wrapper"><h4 id="x4-4-4-alpha-compaction"><bdi class="secno">4.4.4 </bdi><dfn id="3alphaCompaction" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Alpha compaction</dfn></h4><a class="self-link" href="#4Concepts.Alpha-indexing" aria-label="Permalink for Section 4.4.4"></a></div> <p>For non-indexed images, if there exists an RGB (or greyscale) value such that all pixels with that value are fully transparent while all other pixels are fully opaque, then the alpha channel can be represented more compactly by merely identifying the RGB (or greyscale) value that is transparent.</p> </section> <section id="4Concepts.Scaling"><div class="header-wrapper"><h4 id="x4-4-5-sample-depth-scaling"><bdi class="secno">4.4.5 </bdi><dfn id="3sampleDepthScaling" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Sample depth scaling</dfn> </h4><a class="self-link" href="#4Concepts.Scaling" aria-label="Permalink for Section 4.4.5"></a></div> <p>In the PNG image, not all sample depths are supported (see <a href="#6Colour-values" class="sec-ref"><bdi class="secno">6.1 </bdi>Color types and values</a>), and all channels shall have the same sample depth. All channels of the PNG image use the smallest allowable sample depth that is not less than any sample depth in the reference image, and the possible sample values in the reference image are linearly mapped into the next allowable range for the PNG image. <a href="#scaling-sample-values" class="fig-ref" title="Scaling sample values">Figure <bdi class="">5</bdi></a> shows how samples of depth 3 might be mapped into samples of depth 4.</p> <figure id="scaling-sample-values"> <object id="figure45" height="320" width="280" data="figures/scaling-sample-values.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#scaling-sample-values">Figure <bdi class="figno">5</bdi></a> <span class="fig-title"> Scaling sample values </span></figcaption> </figure> <p>Allowing only a few sample depths reduces the number of cases that decoders have to cope with. <a href="#3sampleDepthScaling" class="internalDFN" data-link-type="dfn" id="ref-for-3sampleDepthScaling-2">Sample depth scaling</a> is reversible with no loss of data, because the reference image sample depths can be recorded in the PNG datastream. In the absence of recorded sample depths, the reference image sample depth equals the PNG image sample depth. See <a href="#12Sample-depth-scaling" class="sec-ref"><bdi class="secno">12.4 </bdi>Sample depth scaling</a> and <a href="#13Sample-depth-rescaling" class="sec-ref"><bdi class="secno">13.12 </bdi>Sample depth rescaling</a>.</p> <figure id="possible-pixel-types"> <object id="figure46" data="figures/possible-pixel-types.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#possible-pixel-types">Figure <bdi class="figno">6</bdi></a> <span class="fig-title"> Possible PNG image pixel types </span></figcaption> </figure> </section> </section> <section id="4Concepts.PNGImage"><div class="header-wrapper"><h3 id="x4-5-png-image"><bdi class="secno">4.5 </bdi>PNG image</h3><a class="self-link" href="#4Concepts.PNGImage" aria-label="Permalink for Section 4.5"></a></div> <p>The transformation of the reference image results in one of five types of PNG image (see <a href="#possible-pixel-types" class="fig-ref" title="Possible PNG image pixel types">Figure <bdi class="">6</bdi></a>) :</p> <dl> <dt><dfn id="dfn-truecolor-with-alpha" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Truecolor with alpha</dfn></dt> <dd>Each <a href="#3pixel" class="internalDFN" data-link-type="dfn" id="ref-for-3pixel-3">pixel</a> consists of four <a href="#dfn-sample" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sample-2">samples</a>: red, green, blue and <a href="#3alpha" class="internalDFN" data-link-type="dfn" id="ref-for-3alpha-1">alpha</a>.</dd> <dt><dfn id="dfn-greyscale-with-alpha" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Greyscale with alpha</dfn></dt> <dd>Each <a href="#3pixel" class="internalDFN" data-link-type="dfn" id="ref-for-3pixel-4">pixel</a> consists of two <a href="#dfn-sample" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sample-3">samples</a>: a <a href="#3greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-3greyscale-1">grey sample</a> and an <a href="#3alpha" class="internalDFN" data-link-type="dfn" id="ref-for-3alpha-2">alpha</a> sample.</dd> <dt id="truecolor"><dfn id="3truecolour" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Truecolor</dfn></dt> <dd>Each <a href="#3pixel" class="internalDFN" data-link-type="dfn" id="ref-for-3pixel-5">pixel</a> consists of a triplet of <a href="#dfn-sample" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sample-4">samples</a>: red, green, blue. An optional alpha channel can be specified as a single triplet of red, green, blue <a href="#dfn-sample" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sample-5">samples</a>: <a href="#3pixel" class="internalDFN" data-link-type="dfn" id="ref-for-3pixel-6">pixels</a> of the image whose red, green, blue <a href="#dfn-sample" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sample-6">samples</a> are identical to the red, green, blue <a href="#dfn-sample" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sample-7">samples</a> of the alpha channel are fully transparent; others are fully opaque. If the alpha channel is not present, all <a href="#3pixel" class="internalDFN" data-link-type="dfn" id="ref-for-3pixel-7">pixels</a> are fully opaque.</dd> <dt><dfn id="dfn-greyscale" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Greyscale</dfn></dt> <dd>Each pixel consists of a single <dfn id="3greyscale" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">grey sample</dfn>, which represents overall <a href="#dfn-luminance" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-luminance-1">luminance</a> (on a scale from black to white). An optional alpha channel can be specified as a single <a href="#3greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-3greyscale-2">grey sample</a>: <a href="#3pixel" class="internalDFN" data-link-type="dfn" id="ref-for-3pixel-8">pixels</a> of the image whose <a href="#3greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-3greyscale-3">grey sample</a> is identical to the <a href="#3greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-3greyscale-4">grey sample</a> of the alpha channel are fully transparent; others are fully opaque. If the alpha channel is not present, all <a href="#3pixel" class="internalDFN" data-link-type="dfn" id="ref-for-3pixel-9">pixels</a> are fully opaque.</dd> <dt><a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-6">Indexed-color</a></dt> <dd>Each pixel consists of an index into a palette (and into an associated table of alpha values, if present).</dd> </dl> <p>The format of each pixel depends on the PNG image type and the bit depth. For PNG image types other than indexed-color, the bit depth specifies the number of bits per sample, not the total number of bits per pixel. For <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-7">indexed-color</a> images, the bit depth specifies the number of bits in each palette index, not the sample depth of the colors in the palette or alpha table. Within the pixel the samples appear in the following order, depending on the PNG image type.</p> <ol> <li><a href="#dfn-truecolor-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-truecolor-with-alpha-1">Truecolor with alpha</a>: red, green, blue, alpha.</li> <li><a href="#dfn-greyscale-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-with-alpha-1">Greyscale with alpha</a>: grey, alpha.</li> <li><a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-3">Truecolor</a>: red, green, blue.</li> <li><a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-3">Greyscale</a>: grey.</li> <li><a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-8">Indexed-color</a>: palette index.</li> </ol> </section> <section id="4Concepts.Encoding"><div class="header-wrapper"><h3 id="x4-6-encoding-the-png-image"><bdi class="secno">4.6 </bdi>Encoding the PNG image</h3><a class="self-link" href="#4Concepts.Encoding" aria-label="Permalink for Section 4.6"></a></div> <section class="introductory" id="4Concepts.EncodingIntro"><div class="header-wrapper"><h3 id="introduction-2">Introduction</h3><a class="self-link" href="#4Concepts.EncodingIntro" aria-label="Permalink for this Section"></a></div> <p>A conceptual model of the process of encoding a PNG image is given in <a href="#encoding-png-image" class="fig-ref" title="Encoding the PNG image">Figure <bdi class="">7</bdi></a>. The steps refer to the operations on the array of pixels or indices in the PNG image. The <a href="#3palette" class="internalDFN" data-link-type="dfn" id="ref-for-3palette-1">palette</a> and <a href="#3alphaTable" class="internalDFN" data-link-type="dfn" id="ref-for-3alphaTable-1">alpha table</a> are not encoded in this way.</p> <ol> <li>Pass extraction: to allow for progressive display, the PNG image pixels can be rearranged to form several smaller images called reduced images or passes.</li> <li>Scanline serialization: the image is serialized a scanline at a time. Pixels are ordered left to right in a scanline and scanlines are ordered top to bottom.</li> <li>Filtering: each scanline is transformed into a filtered scanline using one of the defined filter types to prepare the scanline for image compression.</li> <li>Compression: occurs on all the filtered scanlines in the image.</li> <li>Chunking: the compressed image is divided into conveniently sized chunks. An error detection code is added to each chunk.</li> <li>Datastream construction: the chunks are inserted into the datastream.</li> </ol> </section> <section id="4Concepts.EncodingPassAbs"><div class="header-wrapper"><h4 id="x4-6-1-pass-extraction"><bdi class="secno">4.6.1 </bdi>Pass extraction</h4><a class="self-link" href="#4Concepts.EncodingPassAbs" aria-label="Permalink for Section 4.6.1"></a></div> <p><dfn id="3passExtraction" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">Pass extraction</dfn> (see <a href="#encoding-png-image" class="fig-ref" title="Encoding the PNG image">Figure <bdi class="">7</bdi></a>) splits a PNG image into a sequence of <dfn id="3reducedImage" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">reduced images</dfn> where the first image defines a coarse view and subsequent images enhance this coarse view until the last image completes the PNG image. The set of reduced images is also called an interlaced PNG image. Two interlace methods are defined in this specification. The first method is a null method; pixels are stored sequentially from left to right and scanlines from top to bottom. The second method makes multiple scans over the image to produce a sequence of seven reduced images. The seven passes for a sample image are illustrated in <a href="#encoding-png-image" class="fig-ref" title="Encoding the PNG image">Figure <bdi class="">7</bdi></a>. See <a href="#8Interlace" class="sec-ref"><bdi class="secno">8. </bdi>Interlacing and pass extraction</a>.</p> <figure id="encoding-png-image"> <object id="figure47" data="figures/encoding-png-image.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#encoding-png-image">Figure <bdi class="figno">7</bdi></a> <span class="fig-title"> Encoding the PNG image </span></figcaption> </figure> <figure id="pass-extraction"> <object id="figure48" data="figures/pass-extraction.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#pass-extraction">Figure <bdi class="figno">8</bdi></a> <span class="fig-title"> Pass extraction </span></figcaption> </figure> </section> <section id="4Concepts.EncodingScanlineAbs"><div class="header-wrapper"><h4 id="x4-6-2-scanline-serialization"><bdi class="secno">4.6.2 </bdi>Scanline serialization</h4><a class="self-link" href="#4Concepts.EncodingScanlineAbs" aria-label="Permalink for Section 4.6.2"></a></div> <p>Each row of pixels, called a scanline, is represented as a sequence of bytes.</p> </section> <section id="4Concepts.EncodingFiltering"><div class="header-wrapper"><h4 id="x4-6-3-filtering"><bdi class="secno">4.6.3 </bdi>Filtering</h4><a class="self-link" href="#4Concepts.EncodingFiltering" aria-label="Permalink for Section 4.6.3"></a></div> <p>PNG allows <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-1">image data</a> to be filtered before it is compressed. Filtering can improve the compressibility of the data. The filter operation is deterministic, reversible, and lossless. This allows the decompressed data to be reverse-filtered in order to obtain the original data. See <a href="#7Filtering" class="sec-ref"><bdi class="secno">7.3 </bdi>Filtering</a>.</p> </section> <section id="4Concepts.EncodingCompression"><div class="header-wrapper"><h4 id="x4-6-4-compression"><bdi class="secno">4.6.4 </bdi>Compression</h4><a class="self-link" href="#4Concepts.EncodingCompression" aria-label="Permalink for Section 4.6.4"></a></div> <p>The sequence of filtered scanlines in the pass or passes of the PNG image is compressed (see <a href="#compression" class="fig-ref" title="Compression and chunking">Figure <bdi class="">9</bdi></a>) by one of the defined compression methods. The concatenated filtered scanlines form the input to the compression stage. The output from the compression stage is a single compressed datastream. See <a href="#10Compression" class="sec-ref"><bdi class="secno">10. </bdi>Compression</a>.</p> </section> <section id="4Concepts.EncodingChunking"><div class="header-wrapper"><h4 id="x4-6-5-chunking"><bdi class="secno">4.6.5 </bdi>Chunking</h4><a class="self-link" href="#4Concepts.EncodingChunking" aria-label="Permalink for Section 4.6.5"></a></div> <p>Chunking provides a convenient breakdown of the compressed datastream into manageable chunks (see <a href="#compression" class="fig-ref" title="Compression and chunking">Figure <bdi class="">9</bdi></a>). Each chunk has its own redundancy check. See <a href="#11Chunks" class="sec-ref"><bdi class="secno">11. </bdi>Chunk specifications</a>.</p> <figure id="compression"> <object id="figure410" data="figures/compression.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#compression">Figure <bdi class="figno">9</bdi></a> <span class="fig-title"> Compression and chunking </span></figcaption> </figure> </section> </section> <section id="4Concepts.AncillInfo"><div class="header-wrapper"><h3 id="x4-7-additional-information"><bdi class="secno">4.7 </bdi>Additional information</h3><a class="self-link" href="#4Concepts.AncillInfo" aria-label="Permalink for Section 4.7"></a></div> <p>Ancillary information may be associated with an image. Decoders may ignore all or some of the ancillary information. The types of ancillary information provided are described in <a href="#table41" class="table-ref" title="Types of ancillary information">Table <bdi class="">2</bdi></a>.</p> <table id="table41" class="simple numbered"> <caption><a class="self-link" href="#table41">Table <bdi class="tableno">2</bdi></a> <span class="table-title"> Types of ancillary information </span></caption> <tbody><tr> <th>Type of information</th> <th>Description</th> </tr> <tr> <td>Animation information</td> <td> An animated image, defined as a series of frames with associated timing, position and handling information, to be displayed if the viewer is capable of doing so. For other cases such as printers, the <a href="#dfn-static-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-static-image-5">static image</a> will be displayed instead. </td> </tr> <tr> <td>Background color</td> <td>Solid background color to be used when presenting the image if no better option is available.</td> </tr> <tr> <td>Coding-independent code points</td> <td> Identifies the color space by enumerating metadata such as the <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-7">transfer function</a> and color primaries. Originally for <a href="#dfn-sdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sdr-2">SDR</a> and <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-2">HDR</a> video, also used for still and animated images. </td> </tr> <tr> <td>Content Light Level Information</td> <td><a href="#dfn-luminance" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-luminance-2">Luminance</a> of the brightest pixel in the image (or image sequence) and the average luminance level of the brightest frame in the sequence.</td> </tr> <tr> <td>EXIF information</td> <td>Exchangeable image file format metadata such as shutter speed, aperture, and orientation</td> </tr> <tr> <td>Gamma and chromaticity</td> <td> <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-2">Gamma value</a> of the image with respect to the desired output intensity, and <a href="#dfn-chromaticity" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-chromaticity-3">chromaticity</a> characteristics of the RGB values used in the image. </td> </tr> <tr> <td>ICC profile</td> <td>Description of the color space (in the form of an International Color Consortium (ICC) profile) to which the samples in the image conform.</td> </tr> <tr> <td>Image histogram</td> <td>Estimates of how frequently the image uses each palette entry.</td> </tr> <tr> <td>Mastering Display Color Volume</td> <td>Describes the absolute three-dimensional color gamut volume of the display used to prepare the content, including the lightest and darkest colors the mastering display can reproduce. This helps to present the image on the display device.</td> </tr> <tr> <td>Physical pixel dimensions</td> <td>Intended pixel size and aspect ratio to be used in presenting the PNG image.</td> </tr> <tr> <td>Significant bits</td> <td>The number of bits that are significant in the samples.</td> </tr> <tr> <td>sRGB color space</td> <td>A rendering intent (as defined by the International Color Consortium) and an indication that the image samples conform to this color space.</td> </tr> <tr> <td>Suggested palette</td> <td>A reduced palette that may be used when the display device is not capable of displaying the full range of colors in the image.</td> </tr> <tr> <td>Textual data</td> <td>Textual information (which may be compressed) associated with the image.</td> </tr> <tr> <td>Time</td> <td>The time when the PNG image was last modified.</td> </tr> <tr> <td>Transparency</td> <td>Alpha information that allows the reference image to be reconstructed when the alpha channel is not retained in the PNG image.</td> </tr> </tbody></table> </section> <section id="4Concepts.Format"><div class="header-wrapper"><h3 id="x4-8-png-datastream"><bdi class="secno">4.8 </bdi>PNG datastream</h3><a class="self-link" href="#4Concepts.Format" aria-label="Permalink for Section 4.8"></a></div> <section id="4Concepts.FormatChunks"><div class="header-wrapper"><h4 id="x4-8-1-chunks"><bdi class="secno">4.8.1 </bdi>Chunks</h4><a class="self-link" href="#4Concepts.FormatChunks" aria-label="Permalink for Section 4.8.1"></a></div> <p>The PNG datastream consists of a PNG signature (see <a href="#5PNG-file-signature" class="sec-ref"><bdi class="secno">5.2 </bdi>PNG signature</a>) followed by a sequence of chunks (see <a href="#11Chunks" class="sec-ref"><bdi class="secno">11. </bdi>Chunk specifications</a>). Each chunk has a chunk type which specifies its function.</p> </section> <section id="4Concepts.FormatTypes"><div class="header-wrapper"><h4 id="x4-8-2-chunk-types"><bdi class="secno">4.8.2 </bdi>Chunk types</h4><a class="self-link" href="#4Concepts.FormatTypes" aria-label="Permalink for Section 4.8.2"></a></div> <p>Chunk types are four-byte sequences chosen so that they correspond to readable labels when interpreted in the ISO 646.IRV:1991 [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso646" title="Information technology — ISO 7-bit coded character set for information interchange">ISO646</a></cite>] character set. The first four are termed critical chunks, which shall be understood and correctly interpreted according to the provisions of this specification. These are:</p> <ol> <li> <a class="chunk" href="#11IHDR">IHDR</a>: image header, which is the first chunk in a PNG datastream. </li> <li> <a class="chunk" href="#11PLTE">PLTE</a>: palette table associated with indexed PNG images. </li> <li> <a class="chunk" href="#11IDAT">IDAT</a>: image data chunks. </li> <li> <a class="chunk" href="#11IEND">IEND</a>: image trailer, which is the last chunk in a PNG datastream. </li> </ol> <p>The remaining chunk types are termed <dfn class="lint-ignore" id="3ancillaryChunk" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">ancillary chunk</dfn> types, which encoders may generate and decoders may interpret.</p> <ol> <li>Transparency information: <a class="chunk" href="#11tRNS">tRNS</a> (see <a href="#11transinfo" class="sec-ref"><bdi class="secno">11.3.1 </bdi>Transparency information</a>). </li> <li>Color space information: <a class="chunk" href="#11cHRM">cHRM</a>, <a class="chunk" href="#11gAMA">gAMA</a>, <a class="chunk" href="#11iCCP">iCCP</a>, <a class="chunk" href="#11sBIT">sBIT</a>, <a class="chunk" href="#11sRGB">sRGB</a>, <a class="chunk" href="#cICP-chunk">cICP</a>, <a class="chunk" href="#mDCV-chunk">mDCV</a> (see <a href="#11addnlcolinfo" class="sec-ref"><bdi class="secno">11.3.2 </bdi>Color space information</a>). </li> <li>Textual information: <a class="chunk" href="#11iTXt">iTXt</a>, <a class="chunk" href="#11tEXt">tEXt</a>, <a class="chunk" href="#11zTXt">zTXt</a> (see <a href="#11textinfo" class="sec-ref"><bdi class="secno">11.3.3 </bdi>Textual information</a>). </li> <li>Miscellaneous information: <a class="chunk" href="#11bKGD">bKGD</a>, <a class="chunk" href="#11hIST">hIST</a>, <a class="chunk" href="#11pHYs">pHYs</a>, <a class="chunk" href="#11sPLT">sPLT</a>, <a class="chunk" href="#eXIf">eXIf</a> (see <a href="#11addnlsiinfo" class="sec-ref"><bdi class="secno">11.3.4 </bdi>Miscellaneous information</a>). </li> <li>Time information: <a class="chunk" href="#11tIME">tIME</a> (see <a href="#11timestampinfo" class="sec-ref"><bdi class="secno">11.3.5 </bdi>Time stamp information</a>). </li> <li>Animation information: <a class="chunk" href="#acTL-chunk">acTL</a>, <a class="chunk" href="#fcTL-chunk">fcTL</a>, <a class="chunk" href="#fdAT-chunk">fdAT</a> (see <a href="#animation-information" class="sec-ref"><bdi class="secno">11.3.6 </bdi>Animation information</a>). </li> </ol> </section> </section> <section id="apng-frame-based-animation"><div class="header-wrapper"><h3 id="x4-9-apng-frame-based-animation"><bdi class="secno">4.9 </bdi><abbr title="Animated PNG">APNG</abbr>: frame-based animation</h3><a class="self-link" href="#apng-frame-based-animation" aria-label="Permalink for Section 4.9"></a></div> <section class="introductory" id="introduction-0"><div class="header-wrapper"><h3 id="introduction-3">Introduction</h3><a class="self-link" href="#introduction-0" aria-label="Permalink for this Section"></a></div> <p>Animated PNG (<abbr title="Animated PNG">APNG</abbr>) extends the original, static-only PNG format, adding support for <a href="#dfn-frame" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-1">frame</a>-based animated images. It is intended to be a replacement for simple animated images that have traditionally used the GIF format [<cite><a class="bibref" data-link-type="biblio" href="#bib-gif" title="Graphics Interchange Format">GIF</a></cite>], while adding support for 24-bit images and 8-bit transparency, which GIF lacks.</p> <p><abbr title="Animated PNG">APNG</abbr> is backwards-compatible with earlier versions of PNG; a non-animated PNG decoder will ignore the ancillary <abbr title="Animated PNG">APNG</abbr>-specific chunks and display the <a href="#dfn-static-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-static-image-6">static image</a>.</p> </section> <section id="structure"><div class="header-wrapper"><h4 id="x4-9-1-structure"><bdi class="secno">4.9.1 </bdi>Structure</h4><a class="self-link" href="#structure" aria-label="Permalink for Section 4.9.1"></a></div> <p>An <abbr title="Animated PNG">APNG</abbr> stream is a normal PNG stream as defined in previous versions of the PNG Specification, with three additional chunk types describing the animation and providing additional frame data.</p> <p>To be recognized as an <abbr title="Animated PNG">APNG</abbr>, an <a class="chunk" href="#acTL-chunk">acTL</a> chunk must appear in the stream before any <a class="chunk" href="#11IDAT">IDAT</a> chunks. The <a class="chunk" href="#acTL-chunk">acTL</a> structure is <a href="#animation-information">described below</a>.</p> <p>Conceptually, at the beginning of each play the <a href="#dfn-output-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-output-buffer-1">output buffer</a> shall be completely initialized to a <a href="#dfn-fully-transparent-black" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-fully-transparent-black-1">fully transparent black</a> rectangle, with width and height dimensions from the <a class="chunk" href="#11IHDR">IHDR</a> chunk.</p> <p>The static image may be included as the first frame of the animation by the presence of a single <a class="chunk" href="#fcTL-chunk">fcTL</a> chunk before <a class="chunk" href="#11IDAT">IDAT</a>. Otherwise, the static image is not part of the animation.</p> <p>Subsequent frames are encoded in <a class="chunk" href="#fdAT-chunk">fdAT</a> chunks, which have the same structure as <a class="chunk" href="#11IDAT">IDAT</a> chunks, except preceded by a <a href="#4Concepts.APNGSequence">sequence number</a>. Information for each frame about placement and rendering is stored in <a class="chunk" href="#fcTL-chunk">fcTL</a> chunks. The full layout of <a class="chunk" href="#fdAT-chunk">fdAT</a> and <a class="chunk" href="#fcTL-chunk">fcTL</a> chunks is <a href="#animation-information">described below</a>.</p> <p>The boundaries of the entire animation are specified by the width and height parameters of the <a class="chunk" href="#11IHDR">IHDR</a> chunk, regardless of whether the default image is part of the animation. The default image should be appropriately padded with <a href="#dfn-fully-transparent-black" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-fully-transparent-black-2">fully transparent black</a> pixels if extra space will be needed for later frames.</p> <p>Each frame is identical for each play, therefore it is safe for applications to cache the frames.</p> </section> <section id="4Concepts.APNGSequence"><div class="header-wrapper"><h4 id="x4-9-2-sequence-numbers"><bdi class="secno">4.9.2 </bdi>Sequence numbers</h4><a class="self-link" href="#4Concepts.APNGSequence" aria-label="Permalink for Section 4.9.2"></a></div> <p>The <a class="chunk" href="#fcTL-chunk">fcTL</a> and <a class="chunk" href="#fdAT-chunk">fdAT</a> chunks have a zero-based, 4 byte sequence number. Both chunk types share the sequence. The purpose of this number is to detect (and optionally correct) sequence errors in an Animated PNG, since this specification does not impose ordering restrictions on ancillary chunks.</p> <p>The first <a class="chunk" href="#fcTL-chunk">fcTL</a> chunk shall contain sequence number 0, and the sequence numbers in the remaining <a class="chunk" href="#fcTL-chunk">fcTL</a> and <a class="chunk" href="#fdAT-chunk">fdAT</a> chunks shall be in ascending order, with no gaps or duplicates.</p> <p>The tables below illustrate the use of sequence numbers for images with more than one frame, and more than one <a class="chunk" href="#fdAT-chunk">fdAT</a> chunk for the second frame. (<a class="chunk" href="#11IHDR">IHDR</a> and <a class="chunk" href="#11IEND">IEND</a> chunks omitted in these tables, for clarity).</p> <table class="numbered simple" id="table-if-the-static-image-is-also-the-first-frame"> <caption><a class="self-link" href="#table-if-the-static-image-is-also-the-first-frame">Table <bdi class="tableno">3</bdi></a> <span class="table-title"> If the static image is also the first frame </span></caption> <tbody><tr> <th>Sequence number</th> <th>Chunk</th> </tr> <tr> <td>(none)</td> <td> <a class="chunk" href="#acTL-chunk">acTL</a> </td> </tr> <tr> <td>0</td> <td> <a class="chunk" href="#fcTL-chunk">fcTL</a> first frame </td> </tr> <tr> <td>(none)</td> <td> <a class="chunk" href="#11IDAT">IDAT</a> first frame / static image </td> </tr> <tr> <td>1</td> <td> <a class="chunk" href="#fcTL-chunk">fcTL</a> second frame </td> </tr> <tr> <td>2</td> <td> first <a class="chunk" href="#fdAT-chunk">fdAT</a> for second frame </td> </tr> <tr> <td>3</td> <td> second <a class="chunk" href="#fdAT-chunk">fdAT</a> for second frame </td> </tr> </tbody></table> <table class="numbered simple" id="table-if-the-static-image-is-not-part-of-the-animation"> <caption><a class="self-link" href="#table-if-the-static-image-is-not-part-of-the-animation">Table <bdi class="tableno">4</bdi></a> <span class="table-title"> If the static image is not part of the animation </span></caption> <tbody><tr> <th>Sequence number</th> <th>Chunk</th> </tr> <tr> <td>(none)</td> <td> <a class="chunk" href="#acTL-chunk">acTL</a> </td> </tr> <tr> <td>(none)</td> <td> <a class="chunk" href="#11IDAT">IDAT</a> static image </td> </tr> <tr> <td>0</td> <td> <a class="chunk" href="#fcTL-chunk">fcTL</a> first frame </td> </tr> <tr> <td>1</td> <td> first <a class="chunk" href="#fdAT-chunk">fdAT</a> for first frame </td> </tr> <tr> <td>2</td> <td> second <a class="chunk" href="#fdAT-chunk">fdAT</a> for first frame </td> </tr> <tr> <td>3</td> <td> <a class="chunk" href="#fcTL-chunk">fcTL</a> second frame </td> </tr> <tr> <td>4</td> <td> first <a class="chunk" href="#fdAT-chunk">fdAT</a> for second frame </td> </tr> <tr> <td>5</td> <td> second <a class="chunk" href="#fdAT-chunk">fdAT</a> for second frame </td> </tr> </tbody></table> </section> <section id="apng-output-buffer"><div class="header-wrapper"><h4 id="x4-9-3-output-buffer"><bdi class="secno">4.9.3 </bdi>Output buffer</h4><a class="self-link" href="#apng-output-buffer" aria-label="Permalink for Section 4.9.3"></a></div> <p>The <dfn id="dfn-output-buffer" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">output buffer</dfn> is a pixel array with dimensions specified by the width and height parameters of the PNG <a class="chunk" href="#11IHDR">IHDR</a> chunk. Conceptually, each frame is constructed in the output buffer before being <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-2">composited</a> onto the <a href="#dfn-canvas" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-canvas-1">canvas</a>. The contents of the output buffer are available to the decoder. The corners of the output buffer are mapped to the corners of the <a href="#dfn-canvas" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-canvas-2">canvas</a>.</p> </section> <section id="apng-canvas"><div class="header-wrapper"><h4 id="x4-9-4-canvas"><bdi class="secno">4.9.4 </bdi>Canvas</h4><a class="self-link" href="#apng-canvas" aria-label="Permalink for Section 4.9.4"></a></div> <p>The <dfn id="dfn-canvas" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">canvas</dfn> is the area on the output device on which the frames are to be displayed. The contents of the canvas are not necessarily available to the decoder. If a <a class="chunk" href="#11bKGD">bKGD</a> chunk exists, it may be used to fill the canvas if there is no preferable background.</p> </section> </section> <section id="4Concepts.Errors"><div class="header-wrapper"><h3 id="x4-10-error-handling"><bdi class="secno">4.10 </bdi>Error handling</h3><a class="self-link" href="#4Concepts.Errors" aria-label="Permalink for Section 4.10"></a></div> <p>Errors in a PNG datastream fall into two general classes:</p> <ol> <li>transmission errors or damage to a computer file system, which tend to corrupt much or all of the datastream;</li> <li>syntax errors, which appear as invalid values in chunks, or as missing or misplaced chunks. Syntax errors can be caused not only by encoding mistakes, but also by the use of registered or private values, if those values are unknown to the decoder.</li> </ol> <p>PNG decoders should detect errors as early as possible, recover from errors whenever possible, and fail gracefully otherwise. The error handling philosophy is described in detail in <a href="#13Decoders.Errors" class="sec-ref"><bdi class="secno">13.1 </bdi>Error handling</a>.</p> </section> <section class="informative" id="4Concepts.Registration"><div class="header-wrapper"><h3 id="x4-11-extensions"><bdi class="secno">4.11 </bdi>Extensions</h3><a class="self-link" href="#4Concepts.Registration" aria-label="Permalink for Section 4.11"></a></div><p><em>This section is non-normative.</em></p> <p>The PNG format exposes several extension points:</p> <ul> <li> <a href="#sec-defining-new-chunks">chunk type</a>; </li> <li> <a href="#11tEXt">text keyword</a>; and </li> <li> <a href="#dfn-private-field-values" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-private-field-values-1">private field values</a>. </li> </ul> <p>Some of these extension points are reserved by <abbr title="World Wide Web Consortium">W3C</abbr>, while others are available for private use.</p> </section> </section> <section id="5DataRep"><div class="header-wrapper"><h2 id="x5-datastream-structure"><bdi class="secno">5. </bdi>Datastream structure</h2><a class="self-link" href="#5DataRep" aria-label="Permalink for Section 5."></a></div> <section id="5Introduction"><div class="header-wrapper"><h3 id="x5-1-png-datastream"><bdi class="secno">5.1 </bdi>PNG datastream</h3><a class="self-link" href="#5Introduction" aria-label="Permalink for Section 5.1"></a></div> <p>The <dfn id="3PNGdatastream" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">PNG datastream</dfn> consists of a PNG signature followed by a sequence of chunks. It is the result of encoding a <a href="#3PNGimage" class="internalDFN" data-link-type="dfn" id="ref-for-3PNGimage-2">PNG image</a>.</p> <div class="note" role="note" id="issue-container-generatedID-8"><div role="heading" class="note-title marker" id="h-note-8" aria-level="4"><span>Note</span></div><p class="">The term datastream is used rather than "file" to describe a byte sequence that may be only a portion of a file. It is also used to emphasize that the sequence of bytes might be generated and consumed "on the fly", never appearing in a stored file at all.</p></div> </section> <section id="5PNG-file-signature"><div class="header-wrapper"><h3 id="3PNGsignature"><bdi class="secno">5.2 </bdi>PNG signature</h3><a class="self-link" href="#3PNGsignature" aria-label="Permalink for Section 5.2"></a></div> <p>The first eight bytes of a PNG datastream always contain the following hexadecimal values:</p> <pre aria-busy="false"><code class="hljs"> 89 50 4E 47 0D 0A 1A 0A</code></pre> <p>This signature indicates that the remainder of the datastream contains a single PNG image, consisting of a series of chunks beginning with an <a class="chunk" href="#11IHDR">IHDR</a> chunk and ending with an <a class="chunk" href="#11IEND">IEND</a> chunk.</p> <p>This signature differentiates a PNG datastream from other types of <a href="#dfn-datastream" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-datastream-1">datastream</a> and allows early detection of some transmission errors.</p> </section> <section id="5Chunk-layout"><div class="header-wrapper"><h3 id="x5-3-chunk-layout"><bdi class="secno">5.3 </bdi>Chunk layout</h3><a class="self-link" href="#5Chunk-layout" aria-label="Permalink for Section 5.3"></a></div> <p>Each <dfn id="3chunk" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">chunk</dfn> consists of three or four fields (see <a href="#figure411" class="fig-ref" title="Chunk parts">Figure <bdi class="">10</bdi></a>). The meaning of the fields is described in <a href="#table51" class="table-ref" title="Chunk fields">Table <bdi class="">5</bdi></a>. The chunk data field may be empty.</p> <figure id="figure411"> <object style="width: 70vw" data="figures/chunk-parts.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#figure411">Figure <bdi class="figno">10</bdi></a> <span class="fig-title"> Chunk parts </span></figcaption> </figure> <table id="table51" class="numbered simple"> <caption><a class="self-link" href="#table51">Table <bdi class="tableno">5</bdi></a> <span class="table-title"> Chunk fields </span></caption> <tbody><tr> <th>Name</th> <th>Description</th> </tr> <tr> <td>Length</td> <td> A <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-1">PNG four-byte unsigned integer</a> giving the number of bytes in the chunk's data field. The length counts <strong>only</strong> the data field, <strong>not</strong> itself, the chunk type, or the <abbr title="Cyclic Redundancy Code">CRC</abbr>. Zero is a valid length. Although encoders and decoders should treat the length as unsigned, its value shall not exceed 2<sup>31</sup>-1 bytes. </td> </tr> <tr> <td>Chunk Type</td> <td> A sequence of four bytes defining the chunk type. Each byte of a chunk type is restricted to the hexadecimal values 41 to 5A and 61 to 7A. These correspond to the uppercase and lowercase ISO 646 [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso646" title="Information technology — ISO 7-bit coded character set for information interchange">ISO646</a></cite>] letters (<code>A</code>-<code>Z</code> and <code>a</code>-<code>z</code>) respectively for convenience in description and examination of PNG datastreams. Encoders and decoders shall treat the chunk types as fixed binary values, not character strings. For example, it would not be correct to represent the chunk type <a class="chunk" href="#11IDAT">IDAT</a> by the equivalents of those letters in the UCS 2 character set. Additional naming conventions for chunk types are discussed in <a href="#5Chunk-naming-conventions" class="sec-ref"><bdi class="secno">5.4 </bdi>Chunk naming conventions</a>. </td> </tr> <tr> <td>Chunk Data</td> <td>The data bytes appropriate to the chunk type, if any. <span id="zero-length-data">This field can be of zero length.</span></td> </tr> <tr> <td><abbr title="Cyclic Redundancy Code">CRC</abbr></td> <td> A four-byte <abbr title="Cyclic Redundancy Code">CRC</abbr> calculated on the preceding bytes in the chunk, including the chunk type field and chunk data fields, but <strong>not</strong> including the length field. The <abbr title="Cyclic Redundancy Code">CRC</abbr> can be used to check for corruption of the data. The <abbr title="Cyclic Redundancy Code">CRC</abbr> is always present, even for chunks containing no data. See <a href="#5CRC-algorithm" class="sec-ref"><bdi class="secno">5.5 </bdi><abbr title="Cyclic Redundancy Code">CRC</abbr> algorithm</a>. </td> </tr> </tbody></table> <p>The chunk data length may be any number of bytes up to the maximum; therefore, implementors cannot assume that chunks are aligned on any boundaries larger than bytes.</p> </section> <section id="5Chunk-naming-conventions"><div class="header-wrapper"><h3 id="x5-4-chunk-naming-conventions"><bdi class="secno">5.4 </bdi>Chunk naming conventions</h3><a class="self-link" href="#5Chunk-naming-conventions" aria-label="Permalink for Section 5.4"></a></div> <p>Chunk types are chosen to be meaningful names when the bytes of the chunk type are interpreted as ISO 646 letters [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso646" title="Information technology — ISO 7-bit coded character set for information interchange">ISO646</a></cite>]. Chunk types are assigned so that a decoder can determine some properties of a chunk even when the type is not recognized. These rules allow safe, flexible extension of the PNG format, by allowing a PNG decoder to decide what to do when it encounters an unknown chunk.</p> <p>The naming rules are normally of interest only when the decoder does not recognize the chunk's type, as specified at <a href="#13Decoders" class="sec-ref"><bdi class="secno">13. </bdi>PNG decoders and viewers</a>.</p> <p>Four bits of the chunk type, the property bits, namely bit 5 (value 32) of each byte, are used to convey chunk properties. This choice means that a human can read off the assigned properties according to whether the letter corresponding to each byte of the chunk type is uppercase (bit 5 is 0) or lowercase (bit 5 is 1).</p> <p>The property bits are an inherent part of the chunk type, and hence are fixed for any chunk type. Thus, <span class="chunk">CHNK</span> and <span class="chunk">cHNk</span> would be unrelated chunk types, not the same chunk with different properties.</p> <p>The semantics of the property bits are defined in <a href="#table52" class="table-ref" title="Semantics of property bits">Table <bdi class="">6</bdi></a>.</p> <table id="table52" class="numbered simple"> <caption><a class="self-link" href="#table52">Table <bdi class="tableno">6</bdi></a> <span class="table-title"> Semantics of property bits </span></caption> <tbody><tr> <th>Name & location</th> <th>Definition</th> <th>Description</th> </tr> <tr> <td>Ancillary bit: first byte</td> <td>0 (uppercase) = critical,<br> 1 (lowercase) = ancillary.</td> <td> Critical chunks are necessary for successful display of the contents of the datastream, for example the image header chunk (<a class="chunk" href="#11IHDR">IHDR</a>). A decoder trying to extract the image, upon encountering an unknown chunk type in which the ancillary bit is 0, shall indicate to the user that the image contains information it cannot safely interpret.<br> Ancillary chunks are not strictly necessary in order to meaningfully display the contents of the datastream, for example the time chunk ( <a class="chunk" href="#11tIME">tIME</a>). A decoder encountering an unknown chunk type in which the ancillary bit is 1 can safely ignore the chunk and proceed to display the image. </td> </tr> <tr> <td>Private bit: second byte</td> <td>0 (uppercase) = public,<br> 1 (lowercase) = private.</td> <td> Public chunks are reserved for definition by the <abbr title="World Wide Web Consortium">W3C</abbr>. The definition of private chunks is specified at <a href="#12Use-of-private-chunks" class="sec-ref"><bdi class="secno">12.10.1 </bdi>Use of private chunks</a>. The names of private chunks have a lowercase second letter, while the names of public chunks have uppercase second letters. </td> </tr> <tr> <td>Reserved bit: third byte</td> <td>0 (uppercase) in this version of PNG.<br> If the reserved bit is 1, the datastream does not conform to this version of PNG.</td> <td>The significance of the case of the third letter of the chunk name is reserved for possible future extension. In this International Standard, all chunk names shall have uppercase third letters.</td> </tr> <tr> <td>Safe-to-copy bit: fourth byte</td> <td>0 (uppercase) = unsafe to copy,<br> 1 (lowercase) = safe to copy.</td> <td> This property bit is not of interest to pure decoders, but it is needed by <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-2">PNG editors</a>. This bit defines the proper handling of unrecognized chunks in a datastream that is being modified. Rules for <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-3">PNG editors</a> are discussed further in <a href="#14Ordering" class="sec-ref"><bdi class="secno">14.2 </bdi>Behavior of PNG editors</a>. </td> </tr> </tbody></table> <p class="example">The hypothetical chunk type "<span class="chunk">cHNk</span>" has the property bits:</p> <pre aria-busy="false"><code class="hljs javascript">cHNk <-- <span class="hljs-number">32</span> bit chunk type represented <span class="hljs-keyword">in</span> text form |||| |||+- <span class="hljs-title class_">Safe</span>-to-copy bit is <span class="hljs-number">1</span> (lower <span class="hljs-keyword">case</span> letter; bit <span class="hljs-number">5</span> is <span class="hljs-number">1</span>) ||+-- <span class="hljs-title class_">Reserved</span> bit is <span class="hljs-number">0</span> (upper <span class="hljs-keyword">case</span> letter; bit <span class="hljs-number">5</span> is <span class="hljs-number">0</span>) |+--- <span class="hljs-title class_">Private</span> bit is <span class="hljs-number">0</span> (upper <span class="hljs-keyword">case</span> letter; bit <span class="hljs-number">5</span> is <span class="hljs-number">0</span>) +---- <span class="hljs-title class_">Ancillary</span> bit is <span class="hljs-number">1</span> (lower <span class="hljs-keyword">case</span> letter; bit <span class="hljs-number">5</span> is <span class="hljs-number">1</span>)</code></pre> <p>Therefore, this name represents an ancillary, public, safe-to-copy chunk.</p> </section> <section id="5CRC-algorithm"><div class="header-wrapper"><h3 id="x5-5-crc-algorithm"><bdi class="secno">5.5 </bdi><abbr title="Cyclic Redundancy Code">CRC</abbr> algorithm</h3><a class="self-link" href="#5CRC-algorithm" aria-label="Permalink for Section 5.5"></a></div> <p><abbr title="Cyclic Redundancy Code">CRC</abbr> fields are calculated using standardized <abbr title="Cyclic Redundancy Code">CRC</abbr> methods with pre and post conditioning, as defined by [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso-3309" title="ISO/IEC 3309:1993, Information Technology — Telecommunications and information exchange between systems — High-level data link control (HDLC) procedures — Frame structure.">ISO-3309</a></cite>] and [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-t-v.42" title="ITU-T V.42, SERIES V: DATA COMMUNICATION OVER THE TELEPHONE NETWORK. Error-correcting procedures for DCEs using asynchronous-to-synchronous conversion">ITU-T-V.42</a></cite>]. The <abbr title="Cyclic Redundancy Code">CRC</abbr> polynomial employed— which is identical to that used in the GZIP file format specification [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc1952" title="GZIP file format specification version 4.3">RFC1952</a></cite>]— is</p> <p>x<sup>32</sup> + x<sup>26</sup> + x<sup>23</sup> + x<sup>22</sup> + x<sup>16</sup> + x<sup>12</sup> + x<sup>11</sup> + x<sup>10</sup> + x<sup>8</sup> + x<sup>7</sup> + x<sup>5</sup> + x<sup>4</sup> + x<sup>2</sup> + x + 1</p> <p>In PNG, the 32-bit <abbr title="Cyclic Redundancy Code">CRC</abbr> is initialized to all 1's, and then the data from each byte is processed from the least significant bit (1) to the most significant bit (128). After all the data bytes are processed, the <abbr title="Cyclic Redundancy Code">CRC</abbr> is inverted (its ones complement is taken). This value is transmitted (stored in the datastream) <abbr title="Most Significant Byte">MSB</abbr> first. For the purpose of separating into bytes and ordering, the least significant bit of the 32-bit <abbr title="Cyclic Redundancy Code">CRC</abbr> is defined to be the coefficient of the <code>x<sup>31</sup></code> term.</p> <p>Practical calculation of the <abbr title="Cyclic Redundancy Code">CRC</abbr> often employs a precalculated table to accelerate the computation. See <a href="#D-CRCAppendix" class="sec-ref"><bdi class="secno">D. </bdi>Sample <abbr title="Cyclic Redundancy Code">CRC</abbr> implementation</a>.</p> </section> <section id="5ChunkOrdering"><div class="header-wrapper"><h3 id="x5-6-chunk-ordering"><bdi class="secno">5.6 </bdi>Chunk ordering</h3><a class="self-link" href="#5ChunkOrdering" aria-label="Permalink for Section 5.6"></a></div> <p>The constraints on the positioning of the individual chunks are listed in <a href="#table53" class="table-ref" title="Chunk ordering rules">Table <bdi class="">7</bdi></a> and illustrated diagrammatically for static images in <a href="#lattice-diagram-with-plte" class="fig-ref" title="Lattice diagram: Static PNG images with PLTE">Figure <bdi class="">11</bdi></a> and <a href="#lattice-diagram-without-plte" class="fig-ref" title="Lattice diagram: Static PNG images without PLTE">Figure <bdi class="">12</bdi></a>, for animated images where the static image forms the first frame in <a href="#lattice-apng-static-with-plte" class="fig-ref" title="Lattice diagram: Animated PNG images with PLTE, static image forms the first frame">Figure <bdi class="">13</bdi></a> and <a href="#lattice-apng-static-without-plte" class="fig-ref" title="Lattice diagram: Animated PNG images without PLTE, static image forms the first frame">Figure <bdi class="">14</bdi></a>, and for animated images where the static image is not part of the animation in <a href="#lattice-apng-nostatic-with-plte" class="fig-ref" title="Lattice diagram: Animated PNG images with PLTE, static image not part of animation">Figure <bdi class="">15</bdi></a> and <a href="#lattice-apng-nostatic-without-plte" class="fig-ref" title="Lattice diagram: Animated PNG images without PLTE, static image not part of animation">Figure <bdi class="">16</bdi></a>. These lattice diagrams represent the constraints on positioning imposed by this specification. The lines in the diagrams define partial ordering relationships. Chunks higher up shall appear before chunks lower down. Chunks which are horizontally aligned and appear between two other chunk types (higher and lower than the horizontally aligned chunks) may appear in any order between the two higher and lower chunk types to which they are connected. The superscript associated with the chunk type is defined in <a href="#table54" class="table-ref" title="Meaning of symbols used in lattice diagrams">Table <bdi class="">8</bdi></a>. It indicates whether the chunk is mandatory, optional, or may appear more than once. A vertical bar between two chunk types indicates alternatives.</p> <table id="table53" class="numbered simple"> <caption><a class="self-link" href="#table53">Table <bdi class="tableno">7</bdi></a> <span class="table-title"> Chunk ordering rules </span></caption> <tbody><tr> <th colspan="3">Critical chunks<br> (shall appear in this order, except PLTE is optional)</th> </tr> <tr> <th>Chunk name</th> <th>Multiple allowed</th> <th>Ordering constraints</th> </tr> <tr> <td> <a class="chunk" href="#11IHDR">IHDR</a> </td> <td>No</td> <td>Shall be first</td> </tr> <tr> <td> <a class="chunk" href="#11PLTE">PLTE</a> </td> <td>No</td> <td> Before first <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11IDAT">IDAT</a> </td> <td>Yes</td> <td> Multiple <a class="chunk" href="#11IDAT">IDAT</a> chunks shall be consecutive </td> </tr> <tr> <td> <a class="chunk" href="#11IEND">IEND</a> </td> <td>No</td> <td>Shall be last</td> </tr> <tr> <th colspan="3">Ancillary chunks<br> (need not appear in this order)</th> </tr> <tr> <th>Chunk name</th> <th>Multiple allowed</th> <th>Ordering constraints</th> </tr> <tr> <td> <a class="chunk" href="#acTL-chunk">acTL</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11cHRM">cHRM</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#cICP-chunk">cICP</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11gAMA">gAMA</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11iCCP">iCCP</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a>. If the <a class="chunk" href="#11iCCP">iCCP</a> chunk is present, the <a class="chunk" href="#11sRGB">sRGB</a> chunk should not be present. </td> </tr> <tr> <td> <a class="chunk" href="#mDCV-chunk">mDCV</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a>. </td> </tr> <tr> <td> <a class="chunk" href="#cLLI-chunk">cLLI</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a>. </td> </tr> <tr> <td> <a class="chunk" href="#11sBIT">sBIT</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11sRGB">sRGB</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a>. If the <a class="chunk" href="#11sRGB">sRGB</a> chunk is present, the <a class="chunk" href="#11iCCP">iCCP</a> chunk should not be present. </td> </tr> <tr> <td> <a class="chunk" href="#11bKGD">bKGD</a> </td> <td>No</td> <td> After <a class="chunk" href="#11PLTE">PLTE</a>; before <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11hIST">hIST</a> </td> <td>No</td> <td> After <a class="chunk" href="#11PLTE">PLTE</a>; before <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11tRNS">tRNS</a> </td> <td>No</td> <td> After <a class="chunk" href="#11PLTE">PLTE</a>; before <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#eXIf">eXIf</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#fcTL-chunk">fcTL</a> </td> <td>Yes</td> <td> One may occur before <a class="chunk" href="#11IDAT">IDAT</a>; all others shall be after <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11pHYs">pHYs</a> </td> <td>No</td> <td> Before <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11sPLT">sPLT</a> </td> <td>Yes</td> <td> Before <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#fdAT-chunk">fdAT</a> </td> <td>Yes</td> <td> After <a class="chunk" href="#11IDAT">IDAT</a> </td> </tr> <tr> <td> <a class="chunk" href="#11tIME">tIME</a> </td> <td>No</td> <td>None</td> </tr> <tr> <td> <a class="chunk" href="#11iTXt">iTXt</a> </td> <td>Yes</td> <td>None</td> </tr> <tr> <td> <a class="chunk" href="#11tEXt">tEXt</a> </td> <td>Yes</td> <td>None</td> </tr> <tr> <td> <a class="chunk" href="#11zTXt">zTXt</a> </td> <td>Yes</td> <td>None</td> </tr> </tbody></table> <table id="table54" class="numbered simple"> <caption><a class="self-link" href="#table54">Table <bdi class="tableno">8</bdi></a> <span class="table-title"> Meaning of symbols used in lattice diagrams </span></caption> <tbody><tr> <th>Symbol</th> <th>Meaning</th> </tr> <tr> <td>+</td> <td>One or more</td> </tr> <tr> <td>1</td> <td>Only one</td> </tr> <tr> <td>?</td> <td>Zero or one</td> </tr> <tr> <td>*</td> <td>Zero or more</td> </tr> <tr> <td>|</td> <td>Alternative</td> </tr> </tbody></table> <figure id="lattice-diagram-with-plte"> <object id="figure52" data="figures/lattice-diagram-with-plte.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#lattice-diagram-with-plte">Figure <bdi class="figno">11</bdi></a> <span class="fig-title"> Lattice diagram: Static PNG images with <a class="chunk" href="#11PLTE">PLTE</a> </span></figcaption> </figure> <figure id="lattice-diagram-without-plte"> <object id="figure53" data="figures/lattice-diagram-without-plte.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#lattice-diagram-without-plte">Figure <bdi class="figno">12</bdi></a> <span class="fig-title"> Lattice diagram: Static PNG images without <a class="chunk" href="#11PLTE">PLTE</a> </span></figcaption> </figure> <figure id="lattice-apng-static-with-plte"> <object id="figure52a" data="figures/lattice-diagram-apng-static-first-with-plte.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#lattice-apng-static-with-plte">Figure <bdi class="figno">13</bdi></a> <span class="fig-title"> Lattice diagram: Animated PNG images with <a class="chunk" href="#11PLTE">PLTE</a>, static image forms the first frame </span></figcaption> </figure> <figure id="lattice-apng-static-without-plte"> <object id="figure53a" data="figures/lattice-diagram-apng-static-first-without-plte.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#lattice-apng-static-without-plte">Figure <bdi class="figno">14</bdi></a> <span class="fig-title"> Lattice diagram: Animated PNG images without <a class="chunk" href="#11PLTE">PLTE</a>, static image forms the first frame </span></figcaption> </figure> <figure id="lattice-apng-nostatic-with-plte"> <object id="figure52b" data="figures/lattice-diagram-apng-static-notfirst-with-plte.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#lattice-apng-nostatic-with-plte">Figure <bdi class="figno">15</bdi></a> <span class="fig-title"> Lattice diagram: Animated PNG images with <a class="chunk" href="#11PLTE">PLTE</a>, static image not part of animation </span></figcaption> </figure> <figure id="lattice-apng-nostatic-without-plte"> <object id="figure53b" data="figures/lattice-diagram-apng-static-notfirst-without-plte.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#lattice-apng-nostatic-without-plte">Figure <bdi class="figno">16</bdi></a> <span class="fig-title"> Lattice diagram: Animated PNG images without <a class="chunk" href="#11PLTE">PLTE</a>, static image not part of animation </span></figcaption> </figure> </section> <section id="sec-defining-new-chunks"><div class="header-wrapper"><h3 id="x5-7-defining-chunks"><bdi class="secno">5.7 </bdi>Defining chunks</h3><a class="self-link" href="#sec-defining-new-chunks" aria-label="Permalink for Section 5.7"></a></div> <section id="sec-defining-public-chunks-general"><div class="header-wrapper"><h4 id="x5-7-1-general"><bdi class="secno">5.7.1 </bdi>General</h4><a class="self-link" href="#sec-defining-public-chunks-general" aria-label="Permalink for Section 5.7.1"></a></div> <p>All chunks, private and public, <em class="rfc2119">SHOULD</em> be listed at [<cite><a class="bibref" data-link-type="biblio" href="#bib-png-extensions" title="Extensions to the PNG Third Edition Specification, Version 1.6.0">PNG-EXTENSIONS</a></cite>].</p> </section> <section id="sec-defining-public-chunks"><div class="header-wrapper"><h4 id="x5-7-2-defining-public-chunks"><bdi class="secno">5.7.2 </bdi>Defining public chunks</h4><a class="self-link" href="#sec-defining-public-chunks" aria-label="Permalink for Section 5.7.2"></a></div> <p>Public chunks are reserved for definition by the <abbr title="World Wide Web Consortium">W3C</abbr>.</p> <p>Public chunks are intended for broad use consistent with the philosophy of PNG.</p> <p>Organizations and applications are encouraged to submit any chunk that meet the criteria above for definition as a public chunk by the <a href="https://www.w3.org/groups/wg/png">PNG Working Group</a>.</p> <p>The definition as a public chunk is neither automatic nor immediate. A proposed public chunk type <em class="rfc2119">SHALL</em> not be used in publicly available software or datastreams until defined as such.</p> <p>The definition of new critical chunk types is discouraged unless necessary.</p> </section> <section id="sec-defining-private-chunks"><div class="header-wrapper"><h4 id="x5-7-3-defining-private-chunks"><bdi class="secno">5.7.3 </bdi>Defining private chunks</h4><a class="self-link" href="#sec-defining-private-chunks" aria-label="Permalink for Section 5.7.3"></a></div> <p>Organizations and applications <em class="rfc2119">MAY</em> define private chunks for private and experimental use.</p> <p>A private chunk <em class="rfc2119">SHOULD NOT</em> be defined merely to carry textual information of interest to a human user. Instead <a class="chunk" href="#11iTXt">iTXt</a> chunk <em class="rfc2119">SHOULD</em> BE used and corresponding keyword <em class="rfc2119">SHOULD</em> BE used and a suitable keyword defined.</p> <p>Listing private chunks at [<cite><a class="bibref" data-link-type="biblio" href="#bib-png-extensions" title="Extensions to the PNG Third Edition Specification, Version 1.6.0">PNG-EXTENSIONS</a></cite>] reduces, but does not eliminate, the chance that the same private chunk is used for incompatible purposes by different applications. If a private chunk type is used, additional identifying information <em class="rfc2119">SHOULD</em> BE be stored at the beginning of the chunk data to further reduce the risk of conflicts.</p> <p>An ancillary chunk type, not a critical chunk type, <em class="rfc2119">SHOULD</em> be used for all private chunks that store information that is not absolutely essential to view the image.</p> <p>Private critical chunks <em class="rfc2119">SHOULD NOT</em> be defined because PNG datastreams containing such chunks are not portable, and <em class="rfc2119">SHOULD NOT</em> be used in publicly available software or datastreams. If a private critical chunk is essential for an application, it <em class="rfc2119">SHOULD</em> appear near the start of the datastream, so that a standard decoder need not read very far before discovering that it cannot handle the datastream.</p> <p>See <a href="#newchunks" class="sec-ref"><bdi class="secno">B. </bdi>Guidelines for private chunk types</a> for additional guidelines on defining private chunks.</p> </section> </section> <section id="sec-field-value-extensibility"><div class="header-wrapper"><h3 id="x5-8-private-field-values"><bdi class="secno">5.8 </bdi>Private field values</h3><a class="self-link" href="#sec-field-value-extensibility" aria-label="Permalink for Section 5.8"></a></div> <p>Values greater than or equal to 128 in the following fields are <dfn id="dfn-private-field-values" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">private field values</dfn>:</p> <ul> <li> bit depth </li> <li> <a href="#3colourType" id="ref-for-3colourType-1">color type</a> </li> <li> <a href="#10CompressionCM0">compression method</a> </li> <li> <a href="#8InterlaceMethods">interlace method</a> </li> <li> <a href="#9FtIntro">filter method</a> </li> </ul> <p>These <a href="#dfn-private-field-values" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-private-field-values-2">private field values</a> are neither defined nor reserved by this specification.</p> <p><a href="#dfn-private-field-values" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-private-field-values-3">Private field values</a> <em class="rfc2119">MAY</em> be used for experimental or private semantics.</p> <p><a href="#dfn-private-field-values" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-private-field-values-4">Private field values</a> <em class="rfc2119">SHOULD NOT</em> appear in publicly available software or datastreams since they can result in datastreams that are unreadable by PNG decoders as detailed at <a href="#13Decoders" class="sec-ref"><bdi class="secno">13. </bdi>PNG decoders and viewers</a>.</p> </section> </section> <section id="6Transformation"><div class="header-wrapper"><h2 id="x6-reference-image-to-png-image-transformation"><bdi class="secno">6. </bdi>Reference image to PNG image transformation</h2><a class="self-link" href="#6Transformation" aria-label="Permalink for Section 6."></a></div> <section id="6Colour-values"><div class="header-wrapper"><h3 id="x6-1-color-types-and-values"><bdi class="secno">6.1 </bdi>Color types and values</h3><a class="self-link" href="#6Colour-values" aria-label="Permalink for Section 6.1"></a></div> <p>As explained in <a href="#4Concepts.PNGImage" class="sec-ref"><bdi class="secno">4.5 </bdi>PNG image</a> there are five types of PNG image. Corresponding to each type is a <a id="colorType" href="#3colourType" class="internalDFN" data-link-type="dfn"><dfn id="3colourType" data-plurals="color types" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">color type</dfn></a>, which is the sum of the following values: 1 (palette used), 2 (<a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-4">truecolor</a> used) and 4 (alpha used). <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-4">greyscale</a> and <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-5">truecolor</a> images may have an explicit alpha channel. The PNG image types and corresponding <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-3">color types</a> are listed in <a href="#table6.1" class="table-ref" title="PNG image types and color types">Table <bdi class="">9</bdi></a>.</p> <table id="table6.1" class="numbered simple"> <caption><a class="self-link" href="#table6.1">Table <bdi class="tableno">9</bdi></a> <span class="table-title"> PNG image types and color types </span></caption> <tbody><tr> <th>PNG image type</th> <th>Color type</th> </tr> <tr> <td>Greyscale</td> <td>0</td> </tr> <tr> <td>Truecolor</td> <td>2</td> </tr> <tr> <td>Indexed-color</td> <td>3</td> </tr> <tr> <td>Greyscale with alpha</td> <td>4</td> </tr> <tr> <td>Truecolor with alpha</td> <td>6</td> </tr> </tbody></table> <p>The allowed bit depths and sample depths for each PNG image type are listed in <a href="#11IHDR">Image header</a>.</p> <p>Greyscale samples represent luminance if the transfer curve is indicated (by <a class="chunk" href="#11gAMA">gAMA</a>, <a class="chunk" href="#11sRGB">sRGB</a>, <a class="chunk" href="#11iCCP">iCCP</a>) or <a href="#cICP-chunk" class="chunk">cICP</a>; or device-dependent greyscale if not. RGB samples represent calibrated color information if the color space is indicated (by <a class="chunk" href="#11gAMA">gAMA</a> and <a class="chunk" href="#11cHRM">cHRM</a>, <a class="chunk" href="#11sRGB">sRGB</a>, <a class="chunk" href="#11iCCP">iCCP</a>, or <a href="#cICP-chunk" class="chunk">cICP</a>; or uncalibrated device-dependent color if not.</p> <p>Sample values are not necessarily proportional to light intensity; the <a class="chunk" href="#11gAMA">gAMA</a> chunk specifies the relationship between sample values and display output intensity. Viewers are strongly encouraged to compensate properly. See <a href="#4Concepts.ColourSpaces" class="sec-ref"><bdi class="secno">4.3 </bdi>Color spaces</a>, <a href="#13Decoder-gamma-handling" class="sec-ref"><bdi class="secno">13.13 </bdi>Decoder gamma handling</a> and <a href="#C-GammaAppendix" class="sec-ref"><bdi class="secno">C. </bdi>Gamma and chromaticity</a>.</p> </section> <section id="6AlphaRepresentation"><div class="header-wrapper"><h3 id="x6-2-alpha-representation"><bdi class="secno">6.2 </bdi>Alpha representation</h3><a class="self-link" href="#6AlphaRepresentation" aria-label="Permalink for Section 6.2"></a></div> <p>In a PNG datastream transparency may be represented in one of four ways, depending on the PNG image type (see <a href="#4Concepts.Implied-alpha" class="sec-ref"><bdi class="secno">4.4.1 </bdi><span>Alpha separation</span></a> and <a href="#4Concepts.Alpha-indexing" class="sec-ref"><bdi class="secno">4.4.4 </bdi><span>Alpha compaction</span></a>).</p> <ol> <li> <a href="#dfn-truecolor-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-truecolor-with-alpha-2">Truecolor with alpha</a>, <a href="#dfn-greyscale-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-with-alpha-2">greyscale with alpha</a>: an alpha channel is part of the image array. </li> <li> <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-6">truecolor</a>, <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-5">greyscale</a>: A <a class="chunk" href="#11tRNS">tRNS</a> chunk contains a single pixel value distinguishing the fully transparent pixels from the fully opaque pixels. </li> <li><a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-9">Indexed-color</a>: A <a class="chunk" href="#11tRNS">tRNS</a> chunk contains the alpha table that associates an alpha sample with each palette entry. </li> <li> <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-7">truecolor</a>, <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-6">greyscale</a>, <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-10">indexed-color</a>: there is no <a class="chunk" href="#11tRNS">tRNS</a> chunk present and all pixels are fully opaque. </li> </ol> <p>An alpha channel included in the image array has 8-bit or 16-bit samples, the same size as the other samples. The alpha sample for each pixel is stored immediately following the greyscale or RGB samples of the pixel. An alpha value of zero represents full transparency, and a value of 2<sup>sampledepth</sup> - 1 represents full opacity. Intermediate values indicate partially transparent pixels that can be <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-3">composited</a> against a background image to yield the delivered image.</p> <p>The color values in a pixel are not premultiplied by the alpha value assigned to the pixel. This rule is sometimes called "unassociated" or "non-premultiplied" alpha. (Another common technique is to store sample values premultiplied by the alpha value; in effect, such an image is already <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-4">composited</a> against a black background. PNG does <strong>not</strong> use premultiplied alpha. In consequence an image editor can take a PNG image and easily change its transparency.) See <a href="#12Alpha-channel-creation" class="sec-ref"><bdi class="secno">12.3 </bdi>Alpha channel creation</a> and <a href="#13Alpha-channel-processing" class="sec-ref"><bdi class="secno">13.16 </bdi>Alpha channel processing</a>.</p> </section> </section> <section id="7Transformation"><div class="header-wrapper"><h2 id="x7-encoding-the-png-image-as-a-png-datastream"><bdi class="secno">7. </bdi>Encoding the PNG image as a PNG datastream</h2><a class="self-link" href="#7Transformation" aria-label="Permalink for Section 7."></a></div> <section id="7Integers-and-byte-order"><div class="header-wrapper"><h3 id="x7-1-integers-and-byte-order"><bdi class="secno">7.1 </bdi>Integers and byte order</h3><a class="self-link" href="#7Integers-and-byte-order" aria-label="Permalink for Section 7.1"></a></div> <p>All integers that require more than one byte shall be in <a href="#dfn-network-byte-order" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-network-byte-order-1">network byte order</a> (as illustrated in <a href="#integer-representation-in-png" class="fig-ref" title="Integer representation in PNG">Figure <bdi class="">17</bdi></a> ): the most significant byte comes first, then the less significant bytes in descending order of significance (<abbr title="Most Significant Byte">MSB</abbr> <abbr title="Least Significant Byte">LSB</abbr> for two-byte integers, <abbr title="Most Significant Byte">MSB</abbr> B2 B1 <abbr title="Least Significant Byte">LSB</abbr> for four-byte integers). The highest bit (value 128) of a byte is numbered bit 7; the lowest bit (value 1) is numbered bit 0. Values are unsigned unless otherwise noted. Values explicitly noted as signed are represented in two's complement notation.</p> <p><a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-2">PNG four-byte unsigned integers</a> are limited to the range 0 to 2<sup>31</sup>-1 to accommodate languages that have difficulty with unsigned four-byte values.</p> <figure id="integer-representation-in-png"> <object id="figure71" data="figures/integer-representation-in-png.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#integer-representation-in-png">Figure <bdi class="figno">17</bdi></a> <span class="fig-title"> Integer representation in PNG </span></figcaption> </figure> </section> <section id="7Scanline"><div class="header-wrapper"><h3 id="x7-2-scanlines"><bdi class="secno">7.2 </bdi>Scanlines</h3><a class="self-link" href="#7Scanline" aria-label="Permalink for Section 7.2"></a></div> <p>A PNG image (or pass, see <a href="#8Interlace" class="sec-ref"><bdi class="secno">8. </bdi>Interlacing and pass extraction</a>) is a rectangular pixel array, with pixels appearing left-to-right within each scanline, and scanlines appearing top-to-bottom. The size of each pixel is determined by the number of bits per pixel.</p> <p>Pixels within a scanline are always packed into a sequence of bytes with no wasted bits between pixels. Scanlines always begin on byte boundaries. Permitted bit depths and <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-4">color types</a> are restricted so that in all cases the packing is simple and efficient.</p> <p>In PNG images of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-5">color type</a> 0 (greyscale) each pixel is a single sample, which may have precision less than a byte (1, 2, or 4 bits). These samples are packed into bytes with the leftmost sample in the high-order bits of a byte followed by the other samples for the scanline.</p> <p>In PNG images of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-6">color type</a> 3 (indexed-color) each pixel is a single palette index. These indices are packed into bytes in the same way as the samples for <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-7">color type</a> 0.</p> <p>When there are multiple pixels per byte, some low-order bits of the last byte of a scanline may go unused. The contents of these unused bits are not specified.</p> <p>PNG images that are not <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-11">indexed-color</a> images may have sample values with a bit depth of 16. Such sample values are in <a href="#dfn-network-byte-order" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-network-byte-order-2">network byte order</a> (<abbr title="Most Significant Byte">MSB</abbr> first, <abbr title="Least Significant Byte">LSB</abbr> second). PNG permits multi-sample pixels only with 8 and 16-bit samples, so multiple samples of a single pixel are never packed into one byte.</p> </section> <section id="7Filtering"><div class="header-wrapper"><h3 id="x7-3-filtering"><bdi class="secno">7.3 </bdi>Filtering</h3><a class="self-link" href="#7Filtering" aria-label="Permalink for Section 7.3"></a></div> <p>A <dfn id="3filter" data-plurals="filter methods" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">filter method</dfn> is a transformation applied to an array of <a href="#dfn-scanline" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-scanline-2">scanlines</a> with the aim of improving their compressibility.</p> <p>PNG standardizes one <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-1">filter method</a> and several filter types that may be used to prepare <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-2">image data</a> for compression. It transforms the byte sequence into an equal length sequence of bytes preceded by a filter type byte (see <a href="#serializing-and-filtering-scanline" class="fig-ref" title="Serializing and filtering a scanline">Figure <bdi class="">18</bdi></a> for an example).</p> <p>The encoder shall use only a single <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-2">filter method</a> for an interlaced PNG image, but may use different filter types for each scanline in a reduced image. An intelligent encoder can switch filters from one scanline to the next. The method for choosing which filter to employ is left to the encoder.</p> <p>The filter type byte is not considered part of the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-3">image data</a>, but it is included in the datastream sent to the compression step. See <a href="#9Filters" class="sec-ref"><bdi class="secno">9. </bdi>Filtering</a>.</p> <figure id="serializing-and-filtering-scanline"> <object id="figure49" data="figures/serializing-and-filtering-scanline.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#serializing-and-filtering-scanline">Figure <bdi class="figno">18</bdi></a> <span class="fig-title"> Serializing and filtering a scanline </span></figcaption> </figure> </section> </section> <section id="8Interlace"><div class="header-wrapper"><h2 id="x8-interlacing-and-pass-extraction"><bdi class="secno">8. </bdi>Interlacing and pass extraction</h2><a class="self-link" href="#8Interlace" aria-label="Permalink for Section 8."></a></div> <section class="introductory" id="8InterlaceIntro"><div class="header-wrapper"><h3 id="introduction-4">Introduction</h3><a class="self-link" href="#8InterlaceIntro" aria-label="Permalink for this Section"></a></div> <p>Pass extraction (see <a href="#figure48">Figure 4.8</a>) splits a PNG image into a sequence of reduced images (the interlaced PNG image) where the first image defines a coarse view and subsequent images enhance this coarse view until the last image completes the PNG image. This allows progressive display of the interlaced PNG image by the decoder and allows images to "fade in" when they are being displayed on-the-fly. On average, interlacing slightly expands the datastream size, but it can give the user a meaningful display much more rapidly.</p> </section> <section id="8InterlaceMethods"><div class="header-wrapper"><h3 id="x8-1-interlace-methods"><bdi class="secno">8.1 </bdi>Interlace methods</h3><a class="self-link" href="#8InterlaceMethods" aria-label="Permalink for Section 8.1"></a></div> <p>Two interlace methods are defined in this International Standard, methods 0 and 1. Other values of interlace method are reserved for future standardization.</p> <p>With interlace method 0, the null method, pixels are extracted sequentially from left to right, and scanlines sequentially from top to bottom. The interlaced PNG image is a single reduced image.</p> <p>Interlace method 1, known as Adam7, defines seven distinct passes over the image. Each pass transmits a subset of the pixels in the reference image. The pass in which each pixel is transmitted (numbered from 1 to 7) is defined by replicating the following 8-by-8 pattern over the entire image, starting at the upper left corner:</p> <pre aria-busy="false"><code class="hljs">1 6 4 6 2 6 4 6 7 7 7 7 7 7 7 7 5 6 5 6 5 6 5 6 7 7 7 7 7 7 7 7 3 6 4 6 3 6 4 6 7 7 7 7 7 7 7 7 5 6 5 6 5 6 5 6 7 7 7 7 7 7 7 7</code></pre> <p><a href="#figure48">Figure 4.8</a> shows the seven passes of interlace method 1. Within each pass, the selected pixels are transmitted left to right within a scanline, and selected scanlines sequentially from top to bottom. For example, pass 2 contains pixels 4, 12, 20, etc. of scanlines 0, 8, 16, etc. (where scanline 0, pixel 0 is the upper left corner). The last pass contains all of scanlines 1, 3, 5, etc. The transmission order is defined so that all the scanlines transmitted in a pass will have the same number of pixels; this is necessary for proper application of some of the filters. The interlaced PNG image consists of a sequence of seven reduced images. For example, if the PNG image is 16 by 16 pixels, then the third pass will be a reduced image of two scanlines, each containing four pixels (see <a href="#figure48">Figure 4.8</a>).</p> <p>Scanlines that do not completely fill an integral number of bytes are padded as defined in <a href="#7Scanline" class="sec-ref"><bdi class="secno">7.2 </bdi>Scanlines</a>.</p> <div class="note" role="note" id="issue-container-generatedID-9"><div role="heading" class="note-title marker" id="h-note-9" aria-level="4"><span>Note</span></div><p class="">NOTE If the reference image contains fewer than five columns or fewer than five rows, some passes will be empty.</p></div> </section> </section> <section id="9Filters"><div class="header-wrapper"><h2 id="x9-filtering"><bdi class="secno">9. </bdi>Filtering</h2><a class="self-link" href="#9Filters" aria-label="Permalink for Section 9."></a></div> <section id="9FtIntro"><div class="header-wrapper"><h3 id="x9-1-filter-methods-and-filter-types"><bdi class="secno">9.1 </bdi>Filter methods and filter types</h3><a class="self-link" href="#9FtIntro" aria-label="Permalink for Section 9.1"></a></div> <p>Filtering transforms the PNG image with the goal of improving compression. The overall process is depicted in <a href="#encoding-png-image" class="fig-ref" title="Encoding the PNG image">Figure <bdi class="">7</bdi></a> while the specifics of serializing and filtering a scanline are shown in <a href="#serializing-and-filtering-scanline" class="fig-ref" title="Serializing and filtering a scanline">Figure <bdi class="">18</bdi></a>.</p> <p>PNG allows for a number of <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-3">filter methods</a>. All the reduced images in an interlaced image shall use a single <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-4">filter method</a>. Only <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-5">filter method</a> 0 is defined by this specification. Other <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-6">filter methods</a> are reserved for future standardization. <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-7">Filter method</a> 0 provides a set of five filter types, and individual scanlines in each reduced image may use different filter types.</p> <p>PNG imposes no additional restriction on which filter types can be applied to an interlaced PNG image. However, the filter types are not equally effective on all types of data. See <a href="#12Filter-selection" class="sec-ref"><bdi class="secno">12.7 </bdi>Filter selection</a>.</p> <p>Filtering transforms the byte sequence in a scanline to an equal length sequence of bytes preceded by the filter type. Filter type bytes are associated only with non-empty scanlines. No filter type bytes are present in an empty pass. See <a href="#13Progressive-display" class="sec-ref"><bdi class="secno">13.10 </bdi>Interlacing and progressive display</a>.</p> </section> <section id="9Filter-types"><div class="header-wrapper"><h3 id="x9-2-filter-types-for-filter-method-0"><bdi class="secno">9.2 </bdi>Filter types for filter method 0</h3><a class="self-link" href="#9Filter-types" aria-label="Permalink for Section 9.2"></a></div> <p>Filters are applied to <strong>bytes</strong>, not to pixels, regardless of the bit depth or <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-8">color type</a> of the image. The filters operate on the byte sequence formed by a scanline that has been represented as described in <a href="#7Scanline" class="sec-ref"><bdi class="secno">7.2 </bdi>Scanlines</a>. If the image includes an alpha channel, the alpha data is filtered in the same way as the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-4">image data</a>.</p> <p>Filters may use the original values of the following bytes to generate the new byte value:</p> <table class="numbered simple" id="table-named-filter-bytes"> <caption><a class="self-link" href="#table-named-filter-bytes">Table <bdi class="tableno">10</bdi></a> <span class="table-title"> Named filter bytes </span></caption> <tbody><tr> <th>Name</th> <th>Definition</th> </tr> <tr> <td><var>x</var> </td> <td>the byte being filtered;</td> </tr> <tr> <td><var>a</var> </td> <td>the byte corresponding to x in the pixel immediately before the pixel containing x (or the byte immediately before x, when the bit depth is less than 8);</td> </tr> <tr> <td><var>b</var> </td> <td>the byte corresponding to x in the previous scanline;</td> </tr> <tr> <td><var>c</var> </td> <td>the byte corresponding to b in the pixel immediately before the pixel containing b (or the byte immediately before b, when the bit depth is less than 8).</td> </tr> </tbody></table> <figure id="filter-byte-positions"> <object id="figure72" data="figures/filter-bytes.svg" type="image/svg+xml" style="width: 12vw"> </object> <figcaption><a class="self-link" href="#filter-byte-positions">Figure <bdi class="figno">19</bdi></a> <span class="fig-title"> Positions of filter bytes a, b and c relative to x </span></figcaption> </figure> <p><a href="#filter-byte-positions" class="fig-ref" title="Positions of filter bytes a, b and c relative to x">Figure <bdi class="">19</bdi></a> shows the relative positions of the bytes <var>x</var>, <var>a</var>, <var>b</var>, and <var>c</var>.</p> <p><a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-8">Filter method</a> 0 defines five basic filter types as listed in <a href="#9-table91" class="table-ref" title="Filter types">Table <bdi class="">11</bdi></a>. <code>Orig(y)</code> denotes the original (unfiltered) value of byte <var>y</var>. <code>Filt(y)</code> denotes the value after a filter type has been applied. <code>Recon(y)</code> denotes the value after the corresponding reconstruction function has been applied. The Paeth filter type <var>PaethPredictor</var> [<cite><a class="bibref" data-link-type="biblio" href="#bib-paeth" title="Image File Compression Made Easy, in Graphics Gems II, pp. 93-100">Paeth</a></cite>] is defined below.</p> <p><a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-9">Filter method</a> 0 specifies exactly this set of five filter types and this shall not be extended. This ensures that decoders need not decompress the data to determine whether it contains unsupported filter types: it is sufficient to check the <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-10">filter method</a> in <a href="#11IHDR" class="sec-ref"><bdi class="secno">11.2.1 </bdi><span class="chunk">IHDR</span> Image header</a>.</p> <table id="9-table91" class="numbered simple"> <caption><a class="self-link" href="#9-table91">Table <bdi class="tableno">11</bdi></a> <span class="table-title"> Filter types </span></caption> <tbody><tr> <th>Type</th> <th>Name</th> <th>Filter Function</th> <th>Reconstruction Function</th> </tr> <tr> <td>0</td> <td>None</td> <td><code>Filt(x) = Orig(x)</code> </td> <td><code>Recon(x) = Filt(x)</code> </td> </tr> <tr> <td>1</td> <td>Sub</td> <td><code>Filt(x) = Orig(x) - Orig(a)</code> </td> <td><code>Recon(x) = Filt(x) + Recon(a)</code> </td> </tr> <tr> <td>2</td> <td>Up</td> <td><code>Filt(x) = Orig(x) - Orig(b)</code> </td> <td><code>Recon(x) = Filt(x) + Recon(b)</code> </td> </tr> <tr> <td>3</td> <td>Average</td> <td><code>Filt(x) = Orig(x) - floor((Orig(a) + Orig(b)) / 2)</code> </td> <td><code>Recon(x) = Filt(x) + floor((Recon(a) + Recon(b)) / 2)</code> </td> </tr> <tr> <td>4</td> <td>Paeth</td> <td><code>Filt(x) = Orig(x) - PaethPredictor(Orig(a), Orig(b), Orig(c))</code> </td> <td><code>Recon(x) = Filt(x) + PaethPredictor(Recon(a), Recon(b), Recon(c))</code> </td> </tr> </tbody></table> <p>For all filters, the bytes "to the left of" the first pixel in a scanline shall be treated as being zero. For filters that refer to the prior scanline, the entire prior scanline and bytes "to the left of" the first pixel in the prior scanline shall be treated as being zeroes for the first scanline of a reduced image.</p> <p>To reverse the effect of a filter requires the decoded values of the prior pixel on the same scanline, the pixel immediately above the current pixel on the prior scanline, and the pixel just to the left of the pixel above.</p> <p>Unsigned arithmetic modulo 256 is used, so that both the inputs and outputs fit into bytes. Filters are applied to each byte regardless of bit depth. The sequence of <code>Filt</code> values is transmitted as the filtered scanline.</p> </section> <section id="9Filter-type-3-Average"><div class="header-wrapper"><h3 id="x9-3-filter-type-3-average"><bdi class="secno">9.3 </bdi>Filter type 3: Average</h3><a class="self-link" href="#9Filter-type-3-Average" aria-label="Permalink for Section 9.3"></a></div> <p>The sum <code>Orig(a) + Orig(b)</code> shall be performed without overflow (using at least nine-bit arithmetic). <code>floor()</code> indicates that the result of the division is rounded to the next lower integer if fractional; in other words, it is an integer division or right shift operation.</p> </section> <section id="9Filter-type-4-Paeth"><div class="header-wrapper"><h3 id="x9-4-filter-type-4-paeth"><bdi class="secno">9.4 </bdi>Filter type 4: Paeth</h3><a class="self-link" href="#9Filter-type-4-Paeth" aria-label="Permalink for Section 9.4"></a></div> <p>The Paeth filter type computes a simple linear function of the three neighboring pixels (left, above, upper left), then chooses as predictor the neighboring pixel closest to the computed value. The algorithm used in this specification is an adaptation of the technique due to Alan W. Paeth [<cite><a class="bibref" data-link-type="biblio" href="#bib-paeth" title="Image File Compression Made Easy, in Graphics Gems II, pp. 93-100">Paeth</a></cite>].</p> <p>The PaethPredictor function is defined in the code below. The logic of the function and the locations of the bytes <var>a</var>, <var>b</var>, <var>c</var>, and <var>x</var> are shown in <a href="#paethpredictor-function" class="fig-ref" title="The PaethPredictor function">Figure <bdi class="">20</bdi></a>. <var>Pr</var> is the predictor for byte <var>x</var>.</p> <pre aria-busy="false"><code class="hljs javascript">p = a + b - c pa = <span class="hljs-title function_">abs</span>(p - a) pb = <span class="hljs-title function_">abs</span>(p - b) pc = <span class="hljs-title function_">abs</span>(p - c) <span class="hljs-keyword">if</span> pa <= pb and pa <= pc then <span class="hljs-title class_">Pr</span> = a <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> pb <= pc then <span class="hljs-title class_">Pr</span> = b <span class="hljs-keyword">else</span> <span class="hljs-title class_">Pr</span> = c <span class="hljs-keyword">return</span> <span class="hljs-title class_">Pr</span></code></pre> <figure id="paethpredictor-function"> <object id="9-figure91" data="figures/paethpredictor-function.svg" type="image/svg+xml"> </object> <figcaption><a class="self-link" href="#paethpredictor-function">Figure <bdi class="figno">20</bdi></a> <span class="fig-title"> The PaethPredictor function </span></figcaption> </figure> <p>The calculations within the PaethPredictor function shall be performed exactly, without overflow.</p> <p><strong>The order in which the comparisons are performed is critical and shall not be altered.</strong> The function tries to establish in which of the three directions (vertical, horizontal, or diagonal) the gradient of the image is smallest.</p> <p>Exactly the same PaethPredictor function is used by both encoder and decoder.</p> </section> </section> <section id="10Compression"><div class="header-wrapper"><h2 id="x10-compression"><bdi class="secno">10. </bdi>Compression</h2><a class="self-link" href="#10Compression" aria-label="Permalink for Section 10."></a></div> <section id="10CompressionCM0"><div class="header-wrapper"><h3 id="x10-1-compression-method-0"><bdi class="secno">10.1 </bdi>Compression method 0</h3><a class="self-link" href="#10CompressionCM0" aria-label="Permalink for Section 10.1"></a></div> <p>Only PNG compression method 0 is defined by this International Standard. Other values of compression method are reserved for future standardization. PNG compression method 0 is <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-2">deflate</a> compression with a sliding window (which is an upper bound on the distances appearing in the <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-3">deflate</a> stream) of at most 32768 bytes. <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-4">Deflate</a> compression is derived from <a href="#3LZ77" class="internalDFN" data-link-type="dfn" id="ref-for-3LZ77-2">LZ77</a>.</p> <p><a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-5">Deflate</a>-compressed datastreams within PNG are stored in the <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-1">zlib</a> format, which has the structure:</p> <table id="zlib-structure" class="simple numbered"> <tbody><tr> <td>zlib compression method/flags code</td> <td>1 byte</td> </tr> <tr> <td>Additional flags/check bits</td> <td>1 byte</td> </tr> <tr> <td>Compressed data blocks</td> <td>n bytes</td> </tr> <tr> <td>Check value</td> <td>4 bytes</td> </tr> </tbody></table> <p><a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-2">zlib</a> is specified at [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc1950" title="ZLIB Compressed Data Format Specification version 3.3">rfc1950</a></cite>].</p> <p>For PNG compression method 0, the <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-3">zlib</a> compression method/flags code shall specify method code 8 (<a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-6">deflate</a> compression) and an <a href="#3LZ77" class="internalDFN" data-link-type="dfn" id="ref-for-3LZ77-3">LZ77</a> window size of not more than 32768 bytes. The <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-4">zlib</a> compression method number is not the same as the PNG compression method number in the <a class="chunk" href="#11IHDR">IHDR</a> chunk. The additional flags shall not specify a preset dictionary.</p> <p>If the data to be compressed contain 16384 bytes or fewer, the PNG encoder may set the window size by rounding up to a power of 2 (256 minimum). This decreases the memory required for both encoding and decoding, without adversely affecting the compression ratio.</p> <p>The compressed data within the <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-5">zlib</a> datastream are stored as a series of blocks, each of which can represent raw (uncompressed) data, <a href="#3LZ77" class="internalDFN" data-link-type="dfn" id="ref-for-3LZ77-4">LZ77</a>-compressed data encoded with fixed Huffman codes, or <a href="#3LZ77" class="internalDFN" data-link-type="dfn" id="ref-for-3LZ77-5">LZ77</a>-compressed data encoded with custom Huffman codes. A marker bit in the final block identifies it as the last block, allowing the decoder to recognize the end of the compressed datastream. Further details on the compression algorithm and the encoding are given in the <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-7">deflate</a> specification [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc1951" title="DEFLATE Compressed Data Format Specification version 1.3">rfc1951</a></cite>].</p> <p>The check value stored at the end of the <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-6">zlib</a> datastream is calculated on the uncompressed data represented by the datastream. The algorithm used to calculate this is not the same as the <abbr title="Cyclic Redundancy Code">CRC</abbr> calculation used for PNG chunk <abbr title="Cyclic Redundancy Code">CRC</abbr> field values. The <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-7">zlib</a> check value is useful mainly as a cross-check that the <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-8">deflate</a> algorithms are implemented correctly. Verifying the individual PNG chunk CRCs provides confidence that the PNG datastream has been transmitted undamaged.</p> </section> <section id="10CompressionFSL"><div class="header-wrapper"><h3 id="x10-2-compression-of-the-sequence-of-filtered-scanlines"><bdi class="secno">10.2 </bdi>Compression of the sequence of filtered scanlines</h3><a class="self-link" href="#10CompressionFSL" aria-label="Permalink for Section 10.2"></a></div> <p>The sequence of filtered scanlines is compressed and the resulting data stream is split into <a class="chunk" href="#11IDAT">IDAT</a> chunks. The concatenation of the contents of all the <a class="chunk" href="#11IDAT">IDAT</a> chunks makes up a <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-8">zlib</a> datastream. This datastream decompresses to filtered <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-5">image data</a>.</p> <p>It is important to emphasize that the boundaries between <a class="chunk" href="#11IDAT">IDAT</a> chunks are arbitrary and can fall anywhere in the <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-9">zlib</a> datastream. There is not necessarily any correlation between <a class="chunk" href="#11IDAT">IDAT</a> chunk boundaries and <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-9">deflate</a> block boundaries or any other feature of the <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-10">zlib</a> data. For example, it is entirely possible for the terminating <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-11">zlib</a> check value to be split across <a class="chunk" href="#11IDAT">IDAT</a> chunks.</p> <p>Similarly, there is no required correlation between the structure of the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-6">image data</a> (i.e., scanline boundaries) and <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-10">deflate</a> block boundaries or <a class="chunk" href="#11IDAT">IDAT</a> chunk boundaries. The complete filtered PNG image is represented by a single <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-12">zlib</a> datastream that is stored in a number of <a class="chunk" href="#11IDAT">IDAT</a> chunks.</p> </section> <section id="10CompressionOtherUses"><div class="header-wrapper"><h3 id="x10-3-other-uses-of-compression"><bdi class="secno">10.3 </bdi>Other uses of compression</h3><a class="self-link" href="#10CompressionOtherUses" aria-label="Permalink for Section 10.3"></a></div> <p>PNG also uses compression method 0 in <a class="chunk" href="#11iTXt">iTXt</a>, <a class="chunk" href="#11iCCP">iCCP</a>, and <a class="chunk" href="#11zTXt">zTXt</a> chunks. Unlike the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-7">image data</a>, such datastreams are not split across chunks; each such chunk contains an independent <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-13">zlib</a> datastream (see <a href="#10CompressionCM0" class="sec-ref"><bdi class="secno">10.1 </bdi>Compression method 0</a>).</p> </section> </section> <section id="11Chunks"><div class="header-wrapper"><h2 id="x11-chunk-specifications"><bdi class="secno">11. </bdi>Chunk specifications</h2><a class="self-link" href="#11Chunks" aria-label="Permalink for Section 11."></a></div> <section id="11Introduction"><div class="header-wrapper"><h3 id="x11-1-general"><bdi class="secno">11.1 </bdi>General</h3><a class="self-link" href="#11Introduction" aria-label="Permalink for Section 11.1"></a></div> <p>This clause defines chunk used in this specification.</p> </section> <section id="11Critical-chunks"><div class="header-wrapper"><h3 id="x11-2-critical-chunks"><bdi class="secno">11.2 </bdi>Critical chunks</h3><a class="self-link" href="#11Critical-chunks" aria-label="Permalink for Section 11.2"></a></div> <section class="introductory" id="11CcGen"><div class="header-wrapper"><h3 id="introduction-5">Introduction</h3><a class="self-link" href="#11CcGen" aria-label="Permalink for this Section"></a></div> <p>A <dfn id="3criticalChunk" class="lint-ignore" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">critical chunk</dfn> is a chunk that is absolutely required in order to successfully decode a PNG image from a PNG datastream. Extension chunks may be defined as critical chunks (see <a href="#14EditorsExt" class="sec-ref"><bdi class="secno">14. </bdi>Editors</a>), though this practice is strongly discouraged.</p> <p>A valid PNG datastream shall begin with a PNG signature, immediately followed by an <a class="chunk" href="#11IHDR">IHDR</a> chunk, then one or more <a class="chunk" href="#11IDAT">IDAT</a> chunks, and shall end with an <a class="chunk" href="#11IEND">IEND</a> chunk. Only one <a class="chunk" href="#11IHDR">IHDR</a> chunk and one <a class="chunk" href="#11IEND">IEND</a> chunk are allowed in a PNG datastream.</p> </section> <section id="11IHDR"><div class="header-wrapper"><h4 id="x11-2-1-ihdr-image-header"><bdi class="secno">11.2.1 </bdi><span class="chunk">IHDR</span> Image header</h4><a class="self-link" href="#11IHDR" aria-label="Permalink for Section 11.2.1"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">49 48 44 52</code></pre> <p>The <a class="chunk" href="#11IHDR">IHDR</a> chunk shall be the first chunk in the PNG datastream. It contains:</p> <table id="IHDR-structure" class="simple numbered"> <tbody><tr> <td>Width</td> <td>4 bytes</td> </tr> <tr> <td>Height</td> <td>4 bytes</td> </tr> <tr> <td>Bit depth</td> <td>1 byte</td> </tr> <tr> <td>Color type</td> <td>1 byte</td> </tr> <tr> <td>Compression method</td> <td>1 byte</td> </tr> <tr> <td>Filter method</td> <td>1 byte</td> </tr> <tr> <td>Interlace method</td> <td>1 byte</td> </tr> </tbody></table> <p>Width and height give the image dimensions in pixels. They are <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-3">PNG four-byte unsigned integers</a>. Zero is an invalid value.</p> <p id="3bitDepth">Bit depth is a single-byte integer giving the number of bits per sample or per palette index (not per pixel). Valid values are 1, 2, 4, 8, and 16, although not all values are allowed for all <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-9">color types</a>. See <a href="#6Colour-values" class="sec-ref"><bdi class="secno">6.1 </bdi>Color types and values</a>.</p> <p><a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-10">Color type</a> is a single-byte integer.</p> <p>Bit depth restrictions for each <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-11">color type</a> are imposed to simplify implementations and to prohibit combinations that do not compress well. The allowed combinations are defined in <a href="#table111" class="table-ref" title="Allowed combinations of color type and bit depth">Table <bdi class="">12</bdi></a>.</p> <table id="table111" class="numbered simple"> <caption><a class="self-link" href="#table111">Table <bdi class="tableno">12</bdi></a> <span class="table-title"> Allowed combinations of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-12">color type</a> and bit depth </span></caption> <tbody><tr> <th>PNG image type</th> <th>Color type</th> <th>Allowed bit depths</th> <th>Interpretation</th> </tr> <tr> <td>Greyscale</td> <td>0</td> <td>1, 2, 4, 8, 16</td> <td>Each pixel is a greyscale sample</td> </tr> <tr> <td>Truecolor</td> <td>2</td> <td>8, 16</td> <td>Each pixel is an R,G,B triple</td> </tr> <tr> <td>Indexed-color</td> <td>3</td> <td>1, 2, 4, 8</td> <td> Each pixel is a palette index; a <a class="chunk" href="#11PLTE">PLTE</a> chunk shall appear. </td> </tr> <tr> <td>Greyscale with alpha</td> <td>4</td> <td>8, 16</td> <td>Each pixel is a greyscale sample followed by an alpha sample.</td> </tr> <tr> <td>Truecolor with alpha</td> <td>6</td> <td>8, 16</td> <td>Each pixel is an R,G,B triple followed by an alpha sample.</td> </tr> </tbody></table> <p>The sample depth is the same as the bit depth except in the case of <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-12">indexed-color</a> PNG images (<a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-13">color type</a> 3), in which the sample depth is always 8 bits (see <a href="#4Concepts.PNGImage" class="sec-ref"><bdi class="secno">4.5 </bdi>PNG image</a>).</p> <p>Compression method is a single-byte integer that indicates the method used to compress the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-8">image data</a>. Only compression method 0 (<a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-11">deflate</a> compression with a sliding window of at most 32768 bytes) is defined in this specification. All conforming PNG images shall be compressed with this scheme.</p> <p>Filter method is a single-byte integer that indicates the preprocessing method applied to the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-9">image data</a> before compression. Only <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-11">filter method</a> 0 (adaptive filtering with five basic filter types) is defined in this specification. See <a href="#9Filters" class="sec-ref"><bdi class="secno">9. </bdi>Filtering</a> for details.</p> <p>Interlace method is a single-byte integer that indicates the transmission order of the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-10">image data</a>. Two values are defined in this specification: 0 (no interlace) or 1 (Adam7 interlace). See <a href="#8Interlace" class="sec-ref"><bdi class="secno">8. </bdi>Interlacing and pass extraction</a> for details.</p> </section> <section id="11PLTE"><div class="header-wrapper"><h4 id="x11-2-2-plte-palette"><bdi class="secno">11.2.2 </bdi><span class="chunk">PLTE</span> Palette</h4><a class="self-link" href="#11PLTE" aria-label="Permalink for Section 11.2.2"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">50 4C 54 45</code></pre> <p>The <span class="chunk">PLTE</span> chunk contains from 1 to 256 palette entries, each a three-byte series of the form:</p> <table id="PLTE-structure" class="simple numbered"> <tbody><tr> <td>Red</td> <td>1 byte</td> </tr> <tr> <td>Green</td> <td>1 byte</td> </tr> <tr> <td>Blue</td> <td>1 byte</td> </tr> </tbody></table> <p>The number of entries is determined from the chunk length. A chunk length not divisible by 3 is an error.</p> <p>This chunk shall appear for <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-14">color type</a> 3, and may appear for <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-15">color types</a> 2 and 6; it shall not appear for <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-16">color types</a> 0 and 4. There shall not be more than one <span class="chunk">PLTE</span> chunk.</p> <p>For <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-17">color type</a> 3 (indexed-color), the <span class="chunk">PLTE</span> chunk is required. The first entry in <span class="chunk">PLTE</span> is referenced by pixel value 0, the second by pixel value 1, etc. The number of palette entries shall not exceed the range that can be represented in the image bit depth (for example, 2<sup>4</sup> = 16 for a bit depth of 4). It is permissible to have fewer entries than the bit depth would allow. In that case, any out-of-range pixel value found in the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-11">image data</a> is an error.</p> <p>For <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-18">color types</a> 2 and 6 (<a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-8">truecolor</a> and <a href="#dfn-truecolor-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-truecolor-with-alpha-3">truecolor with alpha</a>), the <span class="chunk">PLTE</span> chunk is optional. If present, it provides a suggested set of colors (from 1 to 256) to which the <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-9">truecolor</a> image can be quantized if it cannot be displayed directly. It is, however, recommended that the <a class="chunk" href="#11sPLT">sPLT</a> chunk be used for this purpose, rather than the <span class="chunk">PLTE</span> chunk. If neither <span class="chunk">PLTE</span> nor <a class="chunk" href="#11sPLT">sPLT</a> chunks are present and the image cannot be displayed directly, quantization has to be done by the viewing system. However, it is often preferable for the selection of colors to be done once by the PNG encoder. (See <a href="#12Suggested-palettes" class="sec-ref"><bdi class="secno">12.5 </bdi>Suggested palettes</a>.)</p> <p>Note that the palette uses 8 bits (1 byte) per sample regardless of the image bit depth. In particular, the palette is 8 bits deep even when it is a suggested quantization of a 16-bit <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-10">truecolor</a> image.</p> <p>There is no requirement that the palette entries all be used by the image, nor that they all be different.</p> </section> <section id="11IDAT"><div class="header-wrapper"><h4 id="x11-2-3-idat-image-data"><bdi class="secno">11.2.3 </bdi><span class="chunk">IDAT</span> Image data</h4><a class="self-link" href="#11IDAT" aria-label="Permalink for Section 11.2.3"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">49 44 41 54</code></pre> <p>The <span class="chunk">IDAT</span> chunk contains the actual <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-12">image data</a> which is the output stream of the compression algorithm. See <a href="#9Filters" class="sec-ref"><bdi class="secno">9. </bdi>Filtering</a> and <a href="#10Compression" class="sec-ref"><bdi class="secno">10. </bdi>Compression</a> for details.</p> <p>There may be multiple <span class="chunk">IDAT</span> chunks; if so, they shall appear consecutively with no other intervening chunks. The compressed datastream is then the concatenation of the contents of the data fields of all the <span class="chunk">IDAT</span> chunks (noting that data fields <a href="#zero-length-data">may be of zero length</a>).</p> <p>Some images have unused trailing bytes at the end of the final IDAT chunk. This could happen when an entire buffer is stored rather than just the portion of the buffer which is used. This is undesirable. Preferably, an encoder would not include these unused bytes. If it must, setting the bytes to zero will prevent accidental data sharing. A decoder should ignore these trailing bytes.</p> </section> <section id="11IEND"><div class="header-wrapper"><h4 id="x11-2-4-iend-image-trailer"><bdi class="secno">11.2.4 </bdi><span class="chunk">IEND</span> Image trailer</h4><a class="self-link" href="#11IEND" aria-label="Permalink for Section 11.2.4"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">49 45 4E 44</code></pre> <p>The <span class="chunk">IEND</span> chunk marks the end of the PNG datastream. The chunk's data field is empty.</p> </section> </section> <section id="11Ancillary-chunks"><div class="header-wrapper"><h3 id="x11-3-ancillary-chunks"><bdi class="secno">11.3 </bdi>Ancillary chunks</h3><a class="self-link" href="#11Ancillary-chunks" aria-label="Permalink for Section 11.3"></a></div> <section class="introductory" id="11AcGen"><div class="header-wrapper"><h3 id="introduction-6">Introduction</h3><a class="self-link" href="#11AcGen" aria-label="Permalink for this Section"></a></div> <p>The ancillary chunks defined in this specification are listed in the order in <a href="#4Concepts.FormatTypes" class="sec-ref"><bdi class="secno">4.8.2 </bdi>Chunk types</a>. This is not the order in which they appear in a PNG datastream. Ancillary chunks may be ignored by a decoder. For each ancillary chunk, the actions described are under the assumption that the decoder is not ignoring the chunk.</p> </section> <section id="11transinfo"><div class="header-wrapper"><h4 id="x11-3-1-transparency-information"><bdi class="secno">11.3.1 </bdi>Transparency information</h4><a class="self-link" href="#11transinfo" aria-label="Permalink for Section 11.3.1"></a></div> <section id="11tRNS"><div class="header-wrapper"><h5 id="x11-3-1-1-trns-transparency"><bdi class="secno">11.3.1.1 </bdi><span class="chunk">tRNS</span> Transparency</h5><a class="self-link" href="#11tRNS" aria-label="Permalink for Section 11.3.1.1"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">74 52 4E 53</code></pre> <p>The <span class="chunk">tRNS</span> chunk specifies either alpha values that are associated with palette entries (for <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-13">indexed-color</a> images) or a single transparent color (for <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-7">greyscale</a> and <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-11">truecolor</a> images). The <span class="chunk">tRNS</span> chunk contains: </p> <table id="tRNS-structure" class="simple numbered"> <tbody><tr> <th colspan="2"> <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-19">Color type</a> 0 </th> </tr> <tr> <td>Grey sample value</td> <td>2 bytes</td> </tr> <tr> <th colspan="2"> <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-20">Color type</a> 2 </th> </tr> <tr> <td>Red sample value</td> <td>2 bytes</td> </tr> <tr> <td>Green sample value</td> <td>2 bytes</td> </tr> <tr> <td>Blue sample value</td> <td>2 bytes</td> </tr> <tr> <th colspan="2"> <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-21">Color type</a> 3 </th> </tr> <tr> <td>Alpha for palette index 0</td> <td>1 byte</td> </tr> <tr> <td>Alpha for palette index 1</td> <td>1 byte</td> </tr> <tr> <td>...etc...</td> <td>1 byte</td> </tr> </tbody></table> <p>For <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-22">color type</a> 3 (indexed-color), the <span class="chunk">tRNS</span> chunk contains a series of one-byte alpha values, corresponding to entries in the <a class="chunk" href="#11PLTE">PLTE</a> chunk. Each entry indicates that pixels of the corresponding palette index shall be treated as having the specified alpha value. Alpha values have the same interpretation as in an 8-bit full alpha channel: 0 is fully transparent, 255 is fully opaque, regardless of image bit depth. The <span class="chunk">tRNS</span> chunk shall not contain more alpha values than there are palette entries, but a <span class="chunk">tRNS</span> chunk may contain fewer values than there are palette entries. In this case, the alpha value for all remaining palette entries is assumed to be 255. In the common case in which only palette index 0 need be made transparent, only a one-byte <span class="chunk">tRNS</span> chunk is needed, and when all palette indices are opaque, the <span class="chunk">tRNS</span> chunk may be omitted.</p> <p>For <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-23">color types</a> 0 or 2, two bytes per sample are used regardless of the image bit depth (see <a href="#7Integers-and-byte-order" class="sec-ref"><bdi class="secno">7.1 </bdi>Integers and byte order</a>). Pixels of the specified grey sample value or RGB sample values are treated as transparent (equivalent to alpha value 0); all other pixels are to be treated as fully opaque (alpha value 2<sup>bitdepth</sup>-1). If the image bit depth is less than 16, the least significant bits are used. Encoders should set the other bits to 0, and decoders must mask the other bits to 0 before the value is used.</p> <p>A <span class="chunk">tRNS</span> chunk shall not appear for <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-24">color types</a> 4 and 6, since a full alpha channel is already present in those cases.</p> <div class="note" role="note" id="issue-container-generatedID-10"><div role="heading" class="note-title marker" id="h-note-10" aria-level="6"><span>Note</span></div><p class="">NOTE For 16-bit <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-8">greyscale</a> or <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-12">truecolor</a> data, as described in <a href="#13Sample-depth-rescaling" class="sec-ref"><bdi class="secno">13.12 </bdi>Sample depth rescaling</a>, only <a href="#tRNS-compare-exactly">pixels matching the entire 16-bit values</a> in <span class="chunk">tRNS</span> chunks are transparent. Decoders have to postpone any sample depth rescaling until after the pixels have been tested for transparency.</p></div> </section> </section> <section id="11addnlcolinfo"><div class="header-wrapper"><h4 id="x11-3-2-color-space-information"><bdi class="secno">11.3.2 </bdi>Color space information</h4><a class="self-link" href="#11addnlcolinfo" aria-label="Permalink for Section 11.3.2"></a></div> <section id="11cHRM"><div class="header-wrapper"><h5 id="x11-3-2-1-chrm-primary-chromaticities-and-white-point"><bdi class="secno">11.3.2.1 </bdi><span class="chunk">cHRM</span> Primary chromaticities and white point</h5><a class="self-link" href="#11cHRM" aria-label="Permalink for Section 11.3.2.1"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">63 48 52 4D</code></pre> <p>The <span class="chunk">cHRM</span> chunk may be used to specify the 1931 CIE <i>x,y</i> chromaticities of the red, green, and blue display primaries used in the <a href="#3PNGimage" class="internalDFN" data-link-type="dfn" id="ref-for-3PNGimage-3">PNG image</a>, and the referenced <a href="#dfn-white-point" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-white-point-2">white point</a>. See <a href="#C-GammaAppendix" class="sec-ref"><bdi class="secno">C. </bdi>Gamma and chromaticity</a> for more information. The <a class="chunk" href="#11iCCP">iCCP</a>, and <a class="chunk" href="#11sRGB">sRGB</a> chunks provide more sophisticated support for color management and control.</p> <p>The <span class="chunk">cHRM</span> chunk contains:</p> <table id="cHRM-structure" class="numbered simple"> <caption><a class="self-link" href="#cHRM-structure">Table <bdi class="tableno">13</bdi></a> <span class="table-title"> cHRM chunk components </span></caption> <tbody><tr> <th>Name</th> <th>Size</th> </tr> <tr> <td>White point x</td> <td>4 bytes</td> </tr> <tr> <td>White point y</td> <td>4 bytes</td> </tr> <tr> <td>Red x</td> <td>4 bytes</td> </tr> <tr> <td>Red y</td> <td>4 bytes</td> </tr> <tr> <td>Green x</td> <td>4 bytes</td> </tr> <tr> <td>Green y</td> <td>4 bytes</td> </tr> <tr> <td>Blue x</td> <td>4 bytes</td> </tr> <tr> <td>Blue y</td> <td>4 bytes</td> </tr> </tbody></table> <p>Each value is encoded as a <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-4">PNG four-byte unsigned integer</a>, representing the <i>x</i> or <i>y</i> value times 100000.</p> <p class="example">A value of 0.3127 would be stored as the integer 31270.</p> <p>The <span class="chunk">cHRM</span> chunk is allowed in all PNG datastreams, although it is of little value for <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-9">greyscale</a> images.</p> <p>This chunk is ignored unless it is the <a href="#color-chunk-precendence">highest-precedence color chunk</a> understood by the decoder.</p> </section> <section id="11gAMA"><div class="header-wrapper"><h5 id="x11-3-2-2-gama-image-gamma"><bdi class="secno">11.3.2.2 </bdi><span class="chunk">gAMA</span> Image gamma</h5><a class="self-link" href="#11gAMA" aria-label="Permalink for Section 11.3.2.2"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">67 41 4D 41</code></pre> <p>The <a class="chunk" href="#11gAMA">gAMA</a> chunk specifies a <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-3">gamma value</a>.</p> <p>In fact specifying the desired display output intensity is insufficient. It is also necessary to specify the viewing conditions under which the output is desired. For <span class="chunk">gAMA</span> these are the reference viewing conditions of the sRGB specification [<cite><a class="bibref" data-link-type="biblio" href="#bib-srgb" title="Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB">SRGB</a></cite>]. Adjustment for different viewing conditions is normally handled by a Color Management System. If the adjustment is not performed, the error is usually small. Applications desiring high color fidelity may wish to use an <a class="chunk" href="#11sRGB">sRGB</a>, <a class="chunk" href="#11iCCP">iCCP</a> chunk.</p> <p>The <span class="chunk">gAMA</span> chunk contains:</p> <table id="gAMA-structure" class="simple numbered"> <tbody><tr> <td>Image gamma</td> <td>4 bytes</td> </tr> </tbody></table> <p>The value is encoded as a <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-5">PNG four-byte unsigned integer</a>, representing the <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-4">gamma value</a> times 100000.</p> <p class="example">A <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-5">gamma value</a> of 1/2.2 would be stored as the integer 45455.</p> <p>See <a href="#12Encoder-gamma-handling" class="sec-ref"><bdi class="secno">12.1 </bdi>Encoder gamma handling</a> and <a href="#13Decoder-gamma-handling" class="sec-ref"><bdi class="secno">13.13 </bdi>Decoder gamma handling</a> for more information.</p> <p>This chunk is ignored unless it is the <a href="#color-chunk-precendence">highest-precedence color chunk</a> understood by the decoder.</p> </section> <section id="11iCCP"><div class="header-wrapper"><h5 id="x11-3-2-3-iccp-embedded-icc-profile"><bdi class="secno">11.3.2.3 </bdi><span class="chunk">iCCP</span> Embedded ICC profile</h5><a class="self-link" href="#11iCCP" aria-label="Permalink for Section 11.3.2.3"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">69 43 43 50</code></pre> <p>The <span class="chunk">iCCP</span> chunk contains:</p> <table id="iCCP-structure" class="simple numbered"> <tbody><tr> <td>Profile name</td> <td>1-79 bytes (character string)</td> </tr> <tr> <td>Null separator</td> <td>1 byte (null character)</td> </tr> <tr> <td>Compression method</td> <td>1 byte</td> </tr> <tr> <td>Compressed profile</td> <td>n bytes</td> </tr> </tbody></table> <p>The profile name may be any convenient name for referring to the profile. It is case-sensitive. Profile names shall contain only printable Latin-1 characters and spaces (only code points 0x20-7E and 0xA1-FF are allowed). Leading, trailing, and consecutive spaces are not permitted. The only compression method defined in this specification is method 0 (<a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-14">zlib</a> datastream with <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-12">deflate</a> compression, see <a href="#10CompressionOtherUses" class="sec-ref"><bdi class="secno">10.3 </bdi>Other uses of compression</a>). The compression method entry is followed by a compressed profile that makes up the remainder of the chunk. Decompression of this datastream yields the embedded ICC profile.</p> <p>If the <span class="chunk">iCCP</span> chunk is present, the image samples conform to the color space represented by the embedded ICC profile as defined by the International Color Consortium [<cite><a class="bibref" data-link-type="biblio" href="#bib-icc" title="ICC.1:2022 (Profile version 4.4.0.0)">ICC</a></cite>][<cite><a class="bibref" data-link-type="biblio" href="#bib-iso_15076-1" title="ISO 15076-1:2010 Image technology colour management — Architecture, profile format and data structure — Part 1: Based on ICC.1:2010">ISO_15076-1</a></cite>]. The color space of the ICC profile shall be an RGB color space for color images (<a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-25">color types</a> 2, 3, and 6), or a greyscale color space for <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-10">greyscale</a> images (<a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-26">color types</a> 0 and 4). A PNG encoder that writes the <span class="chunk">iCCP</span> chunk is encouraged to also write <a class="chunk" href="#11gAMA">gAMA</a> and <a class="chunk" href="#11cHRM">cHRM</a> chunks that approximate the ICC profile, to provide compatibility with applications that do not use the <span class="chunk">iCCP</span> chunk.</p> <p> This chunk is ignored unless it is the <a href="#color-chunk-precendence">highest-precedence color chunk</a> understood by the decoder. </p> <p>Unless a <a class="chunk" href="#cICP-chunk">cICP</a> chunk exists, a PNG datastream should contain at most one embedded profile, whether specified explicitly with an <span class="chunk">iCCP</span> or implicitly with an <a class="chunk" href="#srgb-standard-colour-space">sRGB</a> chunk.</p> </section> <section id="11sBIT"><div class="header-wrapper"><h5 id="x11-3-2-4-sbit-significant-bits"><bdi class="secno">11.3.2.4 </bdi><span class="chunk">sBIT</span> Significant bits</h5><a class="self-link" href="#11sBIT" aria-label="Permalink for Section 11.3.2.4"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">73 42 49 54</code></pre> <p>To simplify decoders, PNG specifies that only certain sample depths may be used, and further specifies that sample values should be scaled to the full range of possible values at the sample depth. The <span class="chunk">sBIT</span> chunk defines the original number of significant bits (which can be less than or equal to the sample depth). This allows PNG decoders to recover the original data losslessly even if the data had a sample depth not directly supported by PNG.</p> <p>The <span class="chunk">sBIT</span> chunk contains:</p> <table id="sBIT-structure" class="numbered simple"> <caption><a class="self-link" href="#sBIT-structure">Table <bdi class="tableno">14</bdi></a> <span class="table-title"> sBIT chunk contents </span></caption> <tbody><tr> <th colspan="2">Color type 0</th> </tr> <tr> <td>significant greyscale bits</td> <td>1 byte</td> </tr> <tr> <th colspan="2">Color types 2 and 3</th> </tr> <tr> <td>significant red bits</td> <td>1 byte</td> </tr> <tr> <td>significant green bits</td> <td>1 byte</td> </tr> <tr> <td>significant blue bits</td> <td>1 byte</td> </tr> <tr> <th colspan="2">Color type 4</th> </tr> <tr> <td>significant greyscale bits</td> <td>1 byte</td> </tr> <tr> <td>significant alpha bits</td> <td>1 byte</td> </tr> <tr> <th colspan="2">Color type 6</th> </tr> <tr> <td>significant red bits</td> <td>1 byte</td> </tr> <tr> <td>significant green bits</td> <td>1 byte</td> </tr> <tr> <td>significant blue bits</td> <td>1 byte</td> </tr> <tr> <td>significant alpha bits</td> <td>1 byte</td> </tr> </tbody></table> <p>Each depth specified in <span class="chunk">sBIT</span> shall be greater than zero and less than or equal to the sample depth (which is 8 for <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-14">indexed-color</a> images, and the bit depth given in <a class="chunk" href="#11IHDR">IHDR</a> for other <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-27">color types</a>). Note that <span class="chunk">sBIT</span> does not provide a sample depth for the alpha channel that is implied by a <a class="chunk" href="#11tRNS">tRNS</a> chunk; in that case, all of the sample bits of the alpha channel are to be treated as significant. If the <span class="chunk">sBIT</span> chunk is not present, then all of the sample bits of all channels are to be treated as significant.</p> </section> <section id="11sRGB"><div class="header-wrapper"><h5 id="srgb-standard-colour-space"><bdi class="secno">11.3.2.5 </bdi><span class="chunk">sRGB</span> Standard RGB color space</h5><a class="self-link" href="#srgb-standard-colour-space" aria-label="Permalink for Section 11.3.2.5"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">73 52 47 42</code></pre> <p>If the <span class="chunk">sRGB</span> chunk is present, the image samples conform to the sRGB color space [<cite><a class="bibref" data-link-type="biblio" href="#bib-srgb" title="Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB">SRGB</a></cite>] and should be displayed using the specified rendering intent defined by the International Color Consortium [<cite><a class="bibref" data-link-type="biblio" href="#bib-icc" title="ICC.1:2022 (Profile version 4.4.0.0)">ICC</a></cite>] or [<cite><a class="bibref" data-link-type="biblio" href="#bib-icc-2" title="Specification ICC.2:2019 (Profile version 5.0.0 - iccMAX)">ICC-2</a></cite>].</p> <p>The <span class="chunk">sRGB</span> chunk contains:</p> <table id="sRGB-structure" class="numbered simple"> <caption><a class="self-link" href="#sRGB-structure">Table <bdi class="tableno">15</bdi></a> <span class="table-title"> sRGB chunk contents </span></caption> <tbody><tr> <th>Name</th> <th>Size</th> </tr> <tr> <td>Rendering intent</td> <td>1 byte</td> </tr> </tbody></table> <p>The following values are defined for rendering intent:</p> <table id="rendering-intent-structure" class="numbered simple"> <caption><a class="self-link" href="#rendering-intent-structure">Table <bdi class="tableno">16</bdi></a> <span class="table-title"> Rendering intent values </span></caption> <tbody><tr> <th>Value</th> <th>Name</th> <th>Description</th> </tr> <tr> <td>0</td> <td>Perceptual</td> <td>for images preferring good adaptation to the output device gamut at the expense of colorimetric accuracy, such as photographs.</td> </tr> <tr> <td>1</td> <td>Relative colorimetric</td> <td> for images requiring color appearance matching (relative to the output device <a href="#dfn-white-point" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-white-point-3">white point</a>), such as logos. </td> </tr> <tr> <td>2</td> <td>Saturation</td> <td>for images preferring preservation of saturation at the expense of hue and lightness, such as charts and graphs.</td> </tr> <tr> <td>3</td> <td>Absolute colorimetric</td> <td>for images requiring preservation of absolute colorimetry, such as previews of images destined for a different output device (proofs).</td> </tr> </tbody></table> <p>It is recommended that a PNG encoder that writes the <span class="chunk">sRGB</span> chunk also write a <a class="chunk" href="#11gAMA">gAMA</a> chunk (and optionally a <a class="chunk" href="#11cHRM">cHRM</a> chunk) for compatibility with decoders that do not use the <span class="chunk">sRGB</span> chunk. Only the following values shall be used.</p> <table id="sRGB-gAMA-cHRM" class="numbered simple"> <caption><a class="self-link" href="#sRGB-gAMA-cHRM">Table <bdi class="tableno">17</bdi></a> <span class="table-title"> gAMA and cHRM values for sRGB </span></caption> <tbody><tr> <th colspan="2">gAMA</th> </tr> <tr> <td>Gamma</td> <td>45455</td> </tr> <tr> <th colspan="2">cHRM</th> </tr> <tr> <td>White point x</td> <td>31270</td> </tr> <tr> <td>White point y</td> <td>32900</td> </tr> <tr> <td>Red x</td> <td>64000</td> </tr> <tr> <td>Red y</td> <td>33000</td> </tr> <tr> <td>Green x</td> <td>30000</td> </tr> <tr> <td>Green y</td> <td>60000</td> </tr> <tr> <td>Blue x</td> <td>15000</td> </tr> <tr> <td>Blue y</td> <td>6000</td> </tr> </tbody></table> <p> This chunk is ignored unless it is the <a href="#color-chunk-precendence">highest-precedence color chunk</a> understood by the decoder. </p> <p>It is recommended that the <a class="chunk" href="#11sRGB">sRGB</a> and <a class="chunk" href="#11iCCP">iCCP</a> chunks do not appear simultaneously in a PNG datastream.</p> </section> <section id="cICP-chunk"><div class="header-wrapper"><h5 id="x11-3-2-6-cicp-coding-independent-code-points-for-video-signal-type-identification"><bdi class="secno">11.3.2.6 </bdi><span class="chunk">cICP</span> Coding-independent code points for video signal type identification</h5><a class="self-link" href="#cICP-chunk" aria-label="Permalink for Section 11.3.2.6"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">63 49 43 50</code></pre> <p>If present, the <span class="chunk">cICP</span> chunk specifies the color space (primaries), transfer function, matrix coefficients and scaling factor of the image using the code points specified in [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-t-h.273" title="ITU-T H.273, SERIES H: AUDIOVISUAL AND MULTIMEDIA SYSTEMS Infrastructure of audiovisual services – Coding of moving video. Coding-independent code points for video signal type identification">ITU-T-H.273</a></cite>]. The video format signaling <em class="rfc2119">SHOULD</em> be used when processing the image, including by a decoder or when rendering the image.</p> <p>The cICP chunk consists of four 1-byte unsigned integers to identify the characteristics described above.</p> <p>The following specifies the syntax of the <span class="chunk">cICP</span> chunk:</p> <table id="cICP-chunk-syntax" class="numbered simple"> <caption><a class="self-link" href="#cICP-chunk-syntax">Table <bdi class="tableno">18</bdi></a> <span class="table-title"> cICP chunk components </span></caption> <tbody><tr> <th>Name</th> <th>Size</th> </tr> <tr> <td>Color Primaries</td> <td>1 byte</td> </tr> <tr> <td>Transfer Function</td> <td>1 byte</td> </tr> <tr> <td>Matrix Coefficients</td> <td>1 byte</td> </tr> <tr> <td>Video Full Range Flag</td> <td>1 byte</td> </tr> </tbody></table> <p>Each of the fields of the <span class="chunk">cICP</span> chunk corresponds to the parameter of the same name in [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-t-h.273" title="ITU-T H.273, SERIES H: AUDIOVISUAL AND MULTIMEDIA SYSTEMS Infrastructure of audiovisual services – Coding of moving video. Coding-independent code points for video signal type identification">ITU-T-H.273</a></cite>].</p> <p>RGB is currently the only supported color model in PNG, and as such <code>Matrix Coefficients</code> shall be set to <code>0</code>.</p> <div class="note" role="note" id="issue-container-generatedID-11"><div role="heading" class="note-title marker" id="h-note-11" aria-level="6"><span>Note</span></div><aside class=""> If <code>Video Full Range Flag</code> value is <code>1</code>, then the image is a <a href="#dfn-full-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-full-range-image-1">full-range image</a>. Typically, images in the RGB color representation are stored in the full-range signal quantization, therefore the vast majority of computer graphics and web images, including those used in traditional PNG workflows, are <a href="#dfn-full-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-full-range-image-2">full-range images</a>. If <code>Video Full Range Flag</code> value is <code>0</code>, then the image is a <a href="#dfn-narrow-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-narrow-range-image-1">narrow-range image</a>. Narrow range images are found in video workflows where there are sample values below reference black (0% signal level) or above nominal peak (100% signal level). For example, [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.709" title="ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange">ITU-R-BT.709</a></cite>] specifies that, for 10-bit coding, reference black (called black level) corresponds to a code value of 64 and nominal peak to a code value of 940. In narrow range, momentary excursions defined as overshoots and undershoots exist below reference black and above nominal peak in order to preserve processing artifacts caused by filtering/compression or by uncontrolled lighting without clipping. This can improve image quality during additional stages of processing and compression. The use of undershoot/overshoot has also been used to preserve additional color volume (both light and color) as described in [<cite><a class="bibref" data-link-type="biblio" href="#bib-ebu-r-103" title="Video Signal Tolerance in Digital Television Systems">EBU-R-103</a></cite>]. [<cite><a class="bibref" data-link-type="biblio" href="#bib-smpte-rp-2077" title="Full-Range Image Mapping">SMPTE-RP-2077</a></cite>] describes full range in more detail and includes the mapping from <a href="#dfn-full-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-full-range-image-3">full-range images</a> to <a href="#dfn-narrow-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-narrow-range-image-2">narrow-range images</a> and describes protected code values for SDI (baseband) carriage. </aside></div> <p>If <code>Video Full Range Flag</code> is <code>0</code> (a <a href="#dfn-narrow-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-narrow-range-image-3">narrow-range image</a>), recommended practice is to define transfer functions such as <a href="#dfn-eotf" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-eotf-1"><abbr title="Electro-Optical Transfer Function">EOTF</abbr></a> or inverse <a href="#dfn-oetf" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-oetf-1"><abbr title="Opto-Electrical Transfer Function">OETF</abbr></a> over the extended range, so as to include negative values. This is done as follows: </p> <pre aria-busy="false"><code class="hljs abnf"><span class="hljs-attribute">out</span> <span class="hljs-operator">=</span> sign(in) * TransferFunction(abs(in))</code></pre> <p>The <span class="chunk">cICP</span> chunk <em class="rfc2119">MUST</em> come before the <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a> chunks.</p> <p> This chunk, if understood by the decoder, is the <a href="#color-chunk-precendence">highest-precedence color chunk</a>. </p> <aside class="example" id="ex-cICP-BT.2100-PQ-full"><div class="marker"> <a class="self-link" href="#ex-cICP-BT.2100-PQ-full">Example<bdi> 1</bdi></a> </div> <span class="chunk">cICP</span> chunk field values for a <a href="#dfn-full-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-full-range-image-4">full-range image</a> that uses the color primaries and the <a href="#dfn-pq" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-pq-2">PQ</a> <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-8">transfer function</a> specified at [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>]: <pre aria-busy="false"><code class="hljs">09 10 00 01</code></pre> <p>(Four 1-byte unsigned integers, in hexadecimal)</p> </aside> <aside class="example" id="ex-cICP-BT.2100-HLG-full"><div class="marker"> <a class="self-link" href="#ex-cICP-BT.2100-HLG-full">Example<bdi> 2</bdi></a> </div> <span class="chunk">cICP</span> chunk field values for a <a href="#dfn-full-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-full-range-image-5">full-range image</a> that uses the color primaries and the <a href="#dfn-hlg" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hlg-2">HLG</a> <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-9">transfer function</a> specified at [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>]: <pre aria-busy="false"><code class="hljs">09 12 00 01</code></pre> <p>(Four 1-byte unsigned integers, in hexadecimal)</p> </aside> <aside class="example" id="ex-cICP-BT.709-narrow"><div class="marker"> <a class="self-link" href="#ex-cICP-BT.709-narrow">Example<bdi> 3</bdi></a> </div> <span class="chunk">cICP</span> chunk field values for a <a href="#dfn-narrow-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-narrow-range-image-4">narrow-range image</a> that uses the color primaries and the <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-10">transfer function</a> defined at [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.709" title="ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange">ITU-R-BT.709</a></cite>]: <pre aria-busy="false"><code class="hljs">01 01 00 00</code></pre> <p>(Four 1-byte unsigned integers, in hexadecimal)</p> </aside> <p id="display-p3">In a similar way to the use of the <a href="#srgb-standard-colour-space"><span class="chunk">sRGB</span></a> chunk to compactly signal an sRGB image, <span class="chunk">cICP</span> can be used to compactly signal a Display P3 image [<cite><a class="bibref" data-link-type="biblio" href="#bib-display-p3" title="Display P3">Display-P3</a></cite>]. </p> <aside class="example" id="ex-cICP-Display-P3-full"><div class="marker"> <a class="self-link" href="#ex-cICP-Display-P3-full">Example<bdi> 4</bdi></a> </div> <span class="chunk">cICP</span> chunk field values for a <a href="#dfn-full-range-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-full-range-image-6">full-range image</a> that uses the color primaries and the <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-11">transfer function</a> defined by [<cite><a class="bibref" data-link-type="biblio" href="#bib-display-p3" title="Display P3">Display-P3</a></cite>]: <pre aria-busy="false"><code class="hljs">0C 0D 00 01</code></pre> <p>(Four 1-byte unsigned integers, in hexadecimal)</p> </aside> </section> <section id="mDCV-chunk"><div class="header-wrapper"><h5 id="x11-3-2-7-mdcv-mastering-display-color-volume"><bdi class="secno">11.3.2.7 </bdi><span class="chunk">mDCV</span> Mastering Display Color Volume</h5><a class="self-link" href="#mDCV-chunk" aria-label="Permalink for Section 11.3.2.7"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">6D 44 43 56</code></pre> <p>If present, the <span class="chunk">mDCV</span> chunk characterizes the Mastering Display Color Volume (mDCV) used at the point of content creation, as specified in [<cite><a class="bibref" data-link-type="biblio" href="#bib-smpte-st-2086" title="Mastering Display Color Volume Metadata Supporting High Luminance and Wide Color Gamut Images">SMPTE-ST-2086</a></cite>]. The mDCV chunk provides informative static metadata which allows a target (consumer) display to potentially optimize its tone mapping decisions on a comparison of its inherent capabilities versus the original mastering display's capabilites.</p> <p>mDCV is typically used with the <a href="#dfn-pq" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-pq-3">PQ</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] transfer function and additional <a href="#cLLI-chunk">cLLI</a> metadata and is commonly then called [<cite><a class="bibref" data-link-type="biblio" href="#bib-hdr10" title="HDR10 Media Profile">HDR10</a></cite>] (PQ with ST 2086 static metadata, MaxFALL and MaxCLL). The mDCV chunk may also be included with <a href="#dfn-hlg" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hlg-3">HLG</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] and <a href="#dfn-sdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sdr-3">SDR</a> image formats (for example [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.709" title="ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange">ITU-R-BT.709</a></cite>]). </p> <p>Since mDCV was originally created as supplemental static metadata meant to optimize the tone-mapping of images on a video display target, a cICP chunk must accompany the use of mDCV in order to establish the basic characteristics of the image content. Color Primaries and White Point characteristics can be derived from cICP chunk formats. Specific examples of its most common use-cases for images using both HDR [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] and SDR [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.709" title="ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange">ITU-R-BT.709</a></cite>] are available in [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-t-series-h-supplement-19" title="Series H: Audio Visual and Multimedia Systems - Usage of video signal type code points">ITU-T-Series-H-Supplement-19</a></cite>]. The basic (cICP) characteristics plus the supplemental (mDCV) static metadata may provide valuable information to optimize tone-mapping decisions.</p> <div class="note" role="note" id="issue-container-generatedID-12"><div role="heading" class="note-title marker" id="h-note-12" aria-level="6"><span>Note</span></div><p class=""><a href="https://github.com/w3c/png/issues/319">Issue #319</a> discusses tone-mapping behavior when the <span class="chunk">mDCV</span> chunk is present.</p></div> <p>For <a href="#dfn-sdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sdr-4">SDR</a> images, if mDCV display min/max luminance are unknown, the default characteristics can be derived from the values in [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-t-series-h-supplement-19" title="Series H: Audio Visual and Multimedia Systems - Usage of video signal type code points">ITU-T-Series-H-Supplement-19</a></cite>] Table 11 or from the relevant <a href="#dfn-sdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sdr-5">SDR</a> specification. At present, there is no published, standardized method for translating an SDR image signal from its default viewing condition (display luminance and ambient illumination) to that signalled in the mDCV chunk.</p> <div class="note" role="note" id="issue-container-generatedID-13"><div role="heading" class="note-title marker" id="h-note-13" aria-level="6"><span>Note</span></div><aside class=""> The <a href="#dfn-hlg" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hlg-4">HLG</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] image format does have published methods for translating the image for both changes in display luminance (within [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>]) and ambient illumination (within the accompanying report [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2390" title="High dynamic range television for production and international programme exchange">ITU-R-BT.2390</a></cite>]). This may be used with SDR images. </aside></div> <p>The following specifies the syntax of the <span class="chunk">mDCV</span> chunk:</p> <table id="mDCV-chunk-syntax" class="numbered simple"> <caption><a class="self-link" href="#mDCV-chunk-syntax">Table <bdi class="tableno">19</bdi></a> <span class="table-title"> mDCV chunk components </span></caption> <tbody><tr> <th>Name</th> <th>Size</th> <th>Divisor value</th> </tr> <tr> <td>Mastering display color primary chromaticities (CIE 1931 <i>x,y</i> of R,G,B )</td> <td>12 bytes</td> <td>0.00002</td> </tr> <tr> <td>Mastering display white point chromaticity (CIE 1931 <i>x,y</i>)</td> <td>4 bytes</td> <td>0.00002</td> </tr> <tr> <td>Mastering display maximum luminance (measured in cd/m<sup>2</sup>)</td> <td>4 bytes</td> <td>0.0001</td> </tr> <tr> <td>Mastering display minimum luminance (measured in cd/m<sup>2</sup>)</td> <td>4 bytes</td> <td>0.0001</td> </tr> </tbody></table> <p>The color primaries are encoded as three pairs of <a href="#dfn-png-two-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-two-byte-unsigned-integer-1">PNG two-byte unsigned integer</a>s, in the order <em>x</em> and then <em>y</em>, each representing the x or y primary chromaticity value divided by the divisor value. They are ordered starting with the primary with the largest x chromaticity, followed by the primary with the largest y chromaticity, followed by the remaining primary. For RGB color spaces, this corresponds to the order R, G, B. </p><p> The white point is encoded as a pair of <a href="#dfn-png-two-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-two-byte-unsigned-integer-2">PNG two-byte unsigned integer</a>s, in the order <em>x</em> and then <em>y</em>, each representing the x or y whie chromaticity value divided by the divisor value. </p> <p> The maximum and minimum luminance values are encoded as <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-6">PNG four-byte unsigned integer</a>s, representing the absolute luminance value in cd/m<sup>2</sup> divided by the divisor value. </p> <p>The divisor maps from actual value to stored value. For example, the unitless divisor of 0.00002 for the primaries and white point would store the chromaticity (0.6800, 0.3200) as {34000, 16000}.</p> <p>The <span class="chunk">mDCV</span> chunk <em class="rfc2119">MUST</em> come before the <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11IDAT">IDAT</a> chunks.</p> <p>Below are mDCV examples for [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-3">HDR</a>.</p> <aside class="example" id="example-5"><div class="marker"> <a class="self-link" href="#example-5">Example<bdi> 5</bdi></a> </div> Example <span class="chunk">mDCV</span> chunk mastering display color primaries for <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-4">HDR</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>]: <table id="mDCV-chunk-hdr-primaries-example" class="numbered simple"> <tbody><tr> <th>Name</th> <th>Actual values</th> <th>Stored Decimal values</th> <th>Stored Hexadecimal values</th> </tr> <tr> <td rowspan="3">Color primaries specified in [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2020" title="Parameter values for ultra-high definition television systems for production and international programme exchange">ITU-R-BT.2020</a></cite>]</td> <td>(0.708, 0.292)</td> <td>{ 35400, 14600 }</td> <td>{ 8A 48, 39 08 }</td> </tr> <tr> <td>(0.170, 0.797)</td> <td>{ 8500, 39850 }</td> <td>{ 21 34, 9B AA }</td> </tr> <tr> <td>(0.131, 0.046)</td> <td>{ 6550, 2300 }</td> <td>{ 19 96, 08 FC }</td> </tr> </tbody></table> </aside> <aside class="example" id="example-6"><div class="marker"> <a class="self-link" href="#example-6">Example<bdi> 6</bdi></a> </div> Example <span class="chunk">mDCV</span> chunk mastering display white point for <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-5">HDR</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>]: <table id="mDCV-chunk-hdr-white-point-example" class="numbered simple"> <tbody><tr> <th>Name</th> <th>Actual values</th> <th>Stored Decimal values</th> <th>Stored Hexadecimal values</th> </tr> <tr> <td>Illuminant D65 specified in [<cite><a class="bibref" data-link-type="biblio" href="#bib-smpte-rp-177" title="Derivation of Basic Television Color Equations">SMPTE-RP-177</a></cite>]</td> <td>(0.3127, 0.3290)</td> <td>{ 15635, 16450 }</td> <td>{ 3C 05, 40 42 }</td> </tr> </tbody></table> </aside> <aside class="example" id="example-7"><div class="marker"> <a class="self-link" href="#example-7">Example<bdi> 7</bdi></a> </div> Example <span class="chunk">mDCV</span> chunk mastering display maximum luminance for <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-6">HDR</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>]: <table id="mDCV-chunk-hdr-max-luminance-example" class="numbered simple"> <tbody><tr> <th>Actual value</th> <th>Stored Decimal value</th> <th>Stored Hexadecimal value</th> </tr> <tr> <td>4000 cd/m<sup>2</sup></td> <td>40000000</td> <td>02 62 5A 00</td> </tr> </tbody></table> </aside> <aside class="example" id="example-8"><div class="marker"> <a class="self-link" href="#example-8">Example<bdi> 8</bdi></a> </div> Example <span class="chunk">mDCV</span> chunk mastering display minimum luminance: <table id="mDCV-chunk-hdr-min-luminance-example" class="numbered simple"> <tbody><tr> <th>Actual value</th> <th>Stored Decimal value</th> <th>Stored Hexadecimal value</th> </tr> <tr> <td>0.0005 cd/m<sup>2</sup></td> <td>5</td> <td>00 00 00 05</td> </tr> </tbody></table> </aside> <p>Below are mDCV examples for [<cite><a class="bibref" data-link-type="biblio" href="#bib-display-p3" title="Display P3">Display-P3</a></cite>] <a href="#dfn-sdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-sdr-6">SDR</a>.</p> <aside class="example" id="example-9"><div class="marker"> <a class="self-link" href="#example-9">Example<bdi> 9</bdi></a> </div> Example <span class="chunk">mDCV</span> chunk mastering display color primaries for [<cite><a class="bibref" data-link-type="biblio" href="#bib-display-p3" title="Display P3">Display-P3</a></cite>]: <table id="mDCV-chunk-sdr-primaries-example" class="numbered simple"> <tbody><tr> <th>Name</th> <th>Actual values</th> <th>Stored Decimal values</th> <th>Stored Hexadecimal values</th> </tr> <tr> <td rowspan="3">Color primaries specified in [<cite><a class="bibref" data-link-type="biblio" href="#bib-display-p3" title="Display P3">Display-P3</a></cite>]</td> <td>(0.68, 0.32)</td> <td>{ 34000, 16000 }</td> <td>{ 84 D0, 3E 80 }</td> </tr> <tr> <td>(0.265, 0.69)</td> <td>{ 13520, 34500 }</td> <td>{ 34 D0, 86 C4 }</td> </tr> <tr> <td>(0.15, 0.06)</td> <td>{ 7500, 3000 }</td> <td>{ 1D 4C, 0B B8 }</td> </tr> </tbody></table> </aside> <aside class="example" id="example-10"><div class="marker"> <a class="self-link" href="#example-10">Example<bdi> 10</bdi></a> </div> Example <span class="chunk">mDCV</span> chunk mastering display white point for [<cite><a class="bibref" data-link-type="biblio" href="#bib-display-p3" title="Display P3">Display-P3</a></cite>]: <table id="mDCV-chunk-sdr-white-point-example" class="numbered simple"> <tbody><tr> <th>Name</th> <th>Actual values</th> <th>Stored Decimal values</th> <th>Stored Hexadecimal values</th> </tr> <tr> <td>Illuminant D65 specified in [<cite><a class="bibref" data-link-type="biblio" href="#bib-smpte-rp-177" title="Derivation of Basic Television Color Equations">SMPTE-RP-177</a></cite>]</td> <td>(0.3127, 0.3290)</td> <td>{ 15635, 16450 }</td> <td>{ 3D 13, 40 42 }</td> </tr> </tbody></table> </aside> <aside class="example" id="example-11"><div class="marker"> <a class="self-link" href="#example-11">Example<bdi> 11</bdi></a> </div> Example <span class="chunk">mDCV</span> chunk mastering display maximum luminance for [<cite><a class="bibref" data-link-type="biblio" href="#bib-display-p3" title="Display P3">Display-P3</a></cite>]: <table id="mDCV-chunk-sdr-max-luminance-example" class="numbered simple"> <tbody><tr> <th>Actual value</th> <th>Stored Decimal values</th> <th>Stored Hexadecimal values</th> </tr> <tr> <td>80 cd/m<sup>2</sup></td> <td>800000</td> <td>00 0C 35 00</td> </tr> </tbody></table> </aside> <aside class="example" id="example-12"><div class="marker"> <a class="self-link" href="#example-12">Example<bdi> 12</bdi></a> </div> Example mDCV chunk mastering display minimum luminance for [<cite><a class="bibref" data-link-type="biblio" href="#bib-display-p3" title="Display P3">Display-P3</a></cite>]: <table id="mDCV-chunk-sdr-min-luminance-example" class="numbered simple"> <tbody><tr> <th>Actual value</th> <th>Stored Decimal values</th> <th>Stored Hexadecimal values</th> </tr> <tr> <td>0.05 cd/m<sup>2</sup></td> <td>500</td> <td>00 00 01 F4</td> </tr> </tbody></table> </aside> </section> <section id="cLLI-chunk"><div class="header-wrapper"><h5 id="x11-3-2-8-clli-content-light-level-information"><bdi class="secno">11.3.2.8 </bdi><span class="chunk">cLLI</span> Content Light Level Information</h5><a class="self-link" href="#cLLI-chunk" aria-label="Permalink for Section 11.3.2.8"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">63 4C 4C 49</code></pre> <p>If present, the <span class="chunk">cLLI</span> chunk identifies two characteristics of <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-7">HDR</a> content:</p> <p>The <span class="chunk">cLLI</span> chunk adds static metadata which provides an opportunity to optimize tone mapping of the associated content to a specific target display. This is accomplished by tailoring the tone mapping of the content itself to the specific peak brightness capabilities of the target display to prevent clipping. The method of tone-mapping optimization is currently subjective.</p> <p>MaxCLL (Maximum Content Light Level) uses a static metadata value to indicate the maximum light level of any single pixel (in cd/m<sup>2</sup>, also known as nits) of the entire playback sequence. There is often an algorithmic filter to eliminate false values occurring from processing or noise that could adversely affect intended downstream tone mapping.</p> <p>MaxFALL (Maximum Frame Average Light Level) uses a static metadata value to indicate the maximum value of the <a href="#dfn-frame" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-2">frame</a> average light level (in cd/m<sup>2</sup>, also known as nits) of the entire playback sequence. MaxFALL is calculated by first averaging the decoded luminance values of all the pixels in each frame, and then using the value for the frame with the highest value.</p> <p>The MaxCLL and MaxFALL values are encoded as <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-7">PNG four-byte unsigned integers</a>.</p> <div class="note" role="note" id="issue-container-generatedID-14"><div role="heading" class="note-title marker" id="h-note-14" aria-level="6"><span>Note</span></div><p class="">[<cite><a class="bibref" data-link-type="biblio" href="#bib-cta-861.3-a" title="HDR Static Metadata Extensions (CTA-861.3-A)">CTA-861.3-A</a></cite>] describes the method of calculation for generating the <span class="chunk">cLLI</span> values, but does not specify any filtering. [<cite><a class="bibref" data-link-type="biblio" href="#bib-hdr-static-meta" title="On the Calculation and Usage of HDR Static Content Metadata">HDR-Static-Meta</a></cite>] describes an improved method which rejects extreme values from statistical outliers, noise or ringing from resampling filters, and is recommended for practical implementations. </p></div> <div class="note" role="note" id="issue-container-generatedID-15"><div role="heading" class="note-title marker" id="h-note-15" aria-level="6"><span>Note</span></div><p class="">[<cite><a class="bibref" data-link-type="biblio" href="#bib-smpte-st-2067-21" title="Interoperable Master Format — Application #2E">SMPTE-ST-2067-21</a></cite>] Section 7.5 adds additional information in Section 7.5 in the case where the <span class="chunk">cLLI</span> values are unknown and have not been calculated.</p></div> <div class="note" role="note" id="issue-container-generatedID-16"><div role="heading" class="note-title marker" id="h-note-16" aria-level="6"><span>Note</span></div><p class=""><a href="https://github.com/w3c/png/issues/319">Issue #319</a> discusses tone-mapping behavior when the <span class="chunk">cLLI</span> chunk is present.</p></div> <p>Each <a href="#dfn-frame" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-3">frame</a> is analyzed.</p> <p>A value of zero for either MaxCLL or MaxFALL means that the value is unknown or not currently calculable.</p> <div class="note" role="note" id="issue-container-generatedID-17"><div role="heading" class="note-title marker" id="h-note-17" aria-level="6"><span>Note</span></div><p class="">An example where this will not be calculable is when creating a live animated PNG stream, when not all frames will be available to compute the values until the stream ends. The encoder may wish to use the value zero initially and replace this with the calculated value when the stream ends.</p></div> <p>The following specifies the syntax of the <span class="chunk">cLLI</span> chunk:</p> <table id="cLLI-chunk-syntax" class="numbered simple"> <caption><a class="self-link" href="#cLLI-chunk-syntax">Table <bdi class="tableno">20</bdi></a> <span class="table-title">cLLI chunk components</span></caption> <tbody><tr> <th>Name</th> <th>Size</th> <th>Divisor value</th> </tr> <tr> <td>Maximum Content Light Level (MaxCLL)</td> <td>4 bytes</td> <td>0.0001 cd/m<sup>2</sup></td> </tr> <tr> <td>Maximum Frame-Average Light Level (MaxFALL)</td> <td>4 bytes</td> <td>0.0001 cd/m<sup>2</sup></td> </tr> </tbody></table> <aside class="example" id="example-13"><div class="marker"> <a class="self-link" href="#example-13">Example<bdi> 13</bdi></a> </div> Example <span class="chunk">cLLI</span> chunk Maximum Content Light Level: <table id="cLLI-chunk-max-content-light-level-example" class="numbered simple"> <tbody><tr> <th>Actual value</th> <th>Stored Decimal values</th> <th>Stored Hexadecimal values</th> </tr> <tr> <td>1000 cd/m<sup>2</sup></td> <td>10000000</td> <td>00 98 96 80</td> </tr> </tbody></table> </aside> <aside class="example" id="example-14"><div class="marker"> <a class="self-link" href="#example-14">Example<bdi> 14</bdi></a> </div> Example <span class="chunk">cLLI</span> chunk Maximum Frame-Average Light Level: <table id="cLLI-chunk-max-frame-avg-luminance-example" class="numbered simple"> <tbody><tr> <th>Actual value</th> <th>Stored Decimal values</th> <th>Stored Hexadecimal values</th> </tr> <tr> <td>250 cd/m<sup>2</sup></td> <td>2500000</td> <td>00 26 25 A0</td> </tr> </tbody></table> </aside> </section> </section> <section id="11textinfo"><div class="header-wrapper"><h4 id="x11-3-3-textual-information"><bdi class="secno">11.3.3 </bdi>Textual information</h4><a class="self-link" href="#11textinfo" aria-label="Permalink for Section 11.3.3"></a></div> <section class="introductory" id="11textIntro"><div class="header-wrapper"><h3 id="introduction-7">Introduction</h3><a class="self-link" href="#11textIntro" aria-label="Permalink for this Section"></a></div> <p>PNG provides the <a class="chunk" href="#11tEXt">tEXt</a>, <a class="chunk" href="#11iTXt">iTXt</a>, and <a class="chunk" href="#11zTXt">zTXt</a> chunks for storing text strings associated with the image, such as an image description or copyright notice. Keywords are used to indicate what each text string represents. Any number of such text chunks may appear, and more than one with the same keyword is permitted.</p> </section> <section id="11keywords"><div class="header-wrapper"><h5 id="x11-3-3-1-keywords-and-text-strings"><bdi class="secno">11.3.3.1 </bdi>Keywords and text strings</h5><a class="self-link" href="#11keywords" aria-label="Permalink for Section 11.3.3.1"></a></div> <p>The following keywords are predefined and should be used where appropriate.</p> <table id="keywords-predefined" class="numbered simple"> <caption><a class="self-link" href="#keywords-predefined">Table <bdi class="tableno">21</bdi></a> <span class="table-title"> Predefined keywords </span></caption> <tbody><tr> <th>Keyword value</th> <th>Description</th> </tr> <tr> <td>Title</td> <td>Short (one line) title or caption for image</td> </tr> <tr> <td>Author</td> <td>Name of image's creator</td> </tr> <tr> <td>Description</td> <td>Description of image (possibly long)</td> </tr> <tr> <td>Copyright</td> <td>Copyright notice</td> </tr> <tr> <td>Creation Time</td> <td>Time of original image creation</td> </tr> <tr> <td>Software</td> <td>Software used to create the image</td> </tr> <tr> <td>Disclaimer</td> <td>Legal disclaimer</td> </tr> <tr> <td>Warning</td> <td>Warning of nature of content</td> </tr> <tr> <td>Source</td> <td>Device used to create the image</td> </tr> <tr> <td>Comment</td> <td>Miscellaneous comment</td> </tr> <tr> <td>XML:com.adobe.xmp</td> <td> Extensible Metadata Platform (XMP) information, formatted as required by the XMP specification [<cite><a class="bibref" data-link-type="biblio" href="#bib-xmp" title="Extensible metadata platform (XMP) specification -- Part 1">XMP</a></cite>]. The use of <a class="chunk" href="#11iTXt">iTXt</a>, with Compression Flag set to 0, and both Language Tag and Translated Keyword set to the null string, are recommended for XMP compliance. </td> </tr> <tr> <td>Collection</td> <td>Name of a collection to which the image belongs. An image may belong to one or more collections, each named by a separate text chunk.</td> </tr> </tbody></table> <p>Other keywords <em class="rfc2119">MAY</em> be defined by any application for private or general interest.</p> <p>Keywords <em class="rfc2119">SHOULD</em> be .</p> <ul> <li>reasonably self-explanatory, since the aim is to let other human users understand what the chunk contains; and</li> <li>chosen to minimize the chance that the same keyword is used for incompatible purposes by different applications.</li> </ul> <p>Keywords of general interest <em class="rfc2119">SHOULD</em> be listed in [<cite><a class="bibref" data-link-type="biblio" href="#bib-png-extensions" title="Extensions to the PNG Third Edition Specification, Version 1.6.0">PNG-EXTENSIONS</a></cite>].</p> <p>Keywords shall contain only printable Latin-1 [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso_8859-1" title="ISO/IEC 8859-1:1998, Information technology — 8-bit single-byte coded graphic character sets — Part 1: Latin alphabet No. 1.">ISO_8859-1</a></cite>] characters and spaces; that is, only code points 0x20-7E and 0xA1-FF are allowed. To reduce the chances for human misreading of a keyword, leading spaces, trailing spaces, and consecutive spaces are not permitted in keywords, nor is U+00A0 NON-BREAKING SPACE since it is visually indistinguishable from an ordinary space.</p> <p>Keywords shall be spelled exactly as registered, so that decoders can use simple literal comparisons when looking for particular keywords. In particular, keywords are considered case-sensitive. Keywords are restricted to 1 to 79 bytes in length.</p> <p>For the Creation Time keyword, the date format <em class="rfc2119">SHOULD</em> be in the RFC 3339 [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc3339" title="Date and Time on the Internet: Timestamps">rfc3339</a></cite>] date-time format or in the date format defined in section 5.2.14 of RFC 1123 [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc1123" title="Requirements for Internet Hosts - Application and Support">rfc1123</a></cite>]. The RFC3339 date-time format is preferred. The actual format of this field is undefined.</p> <p>The <a class="chunk" href="#11iTXt">iTXt</a> chunk uses the UTF-8 encoding [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc3629" title="UTF-8, a transformation format of ISO 10646">rfc3629</a></cite>] and can be used to convey characters in any language. There is an option to compress text strings in the <a class="chunk" href="#11iTXt">iTXt</a> chunk. <a class="chunk" href="#11iTXt">iTXt</a> is recommended for all text strings, as it supports Unicode. There are also <a class="chunk" href="#11tEXt">tEXt</a> and <a class="chunk" href="#11zTXt">zTXt</a> chunks, whose content is restricted to the printable Latin-1 character set plus U+000A LINE FEED (LF). Text strings in <a class="chunk" href="#11zTXt">zTXt</a> are compressed into <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-15">zlib</a> datastreams using <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-13">deflate</a> compression (see <a href="#10CompressionOtherUses" class="sec-ref"><bdi class="secno">10.3 </bdi>Other uses of compression</a>).</p> </section> <section id="11tEXt"><div class="header-wrapper"><h5 id="x11-3-3-2-text-textual-data"><bdi class="secno">11.3.3.2 </bdi><span class="chunk">tEXt</span> Textual data</h5><a class="self-link" href="#11tEXt" aria-label="Permalink for Section 11.3.3.2"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">74 45 58 74</code></pre> <p>Each <span class="chunk">tEXt</span> chunk contains a keyword and a text string, in the format:</p> <table id="tEXt-structure" class="simple numbered"> <tbody><tr> <td>Keyword</td> <td>1-79 bytes (character string)</td> </tr> <tr> <td>Null separator</td> <td>1 byte (null character)</td> </tr> <tr> <td>Text string</td> <td>0 or more bytes (character string)</td> </tr> </tbody></table> <p>The keyword and text string are separated by a zero byte (null character). Neither the keyword nor the text string may contain a null character. The text string is <strong>not</strong> null-terminated (the length of the chunk defines the ending). The text string may be of any length from zero bytes up to the maximum permissible chunk size less the length of the keyword and null character separator.</p> <p>The keyword indicates the type of information represented by the text string as described in <a href="#11keywords" class="sec-ref"><bdi class="secno">11.3.3.1 </bdi>Keywords and text strings</a>.</p> <p>Text is interpreted according to the Latin-1 character set [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso_8859-1" title="ISO/IEC 8859-1:1998, Information technology — 8-bit single-byte coded graphic character sets — Part 1: Latin alphabet No. 1.">ISO_8859-1</a></cite>]. The text string may contain any Latin-1 character. Newlines in the text string should be represented by a single linefeed character (decimal 10). Characters other than those defined in Latin-1 plus the linefeed character have no defined meaning in <span class="chunk">tEXt</span> chunks. Text containing characters outside the repertoire of ISO/IEC 8859-1 should be encoded using the <a class="chunk" href="#11iTXt">iTXt</a> chunk.</p> </section> <section id="11zTXt"><div class="header-wrapper"><h5 id="x11-3-3-3-ztxt-compressed-textual-data"><bdi class="secno">11.3.3.3 </bdi><span class="chunk">zTXt</span> Compressed textual data</h5><a class="self-link" href="#11zTXt" aria-label="Permalink for Section 11.3.3.3"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">7A 54 58 74</code></pre> <p>The <span class="chunk">zTXt</span> and <a class="chunk" href="#11tEXt">tEXt</a> chunks are semantically equivalent, but the <span class="chunk">zTXt</span> chunk is recommended for storing large blocks of text.</p> <p>A <span class="chunk">zTXt</span> chunk contains:</p> <table id="zTXt-structure" class="simple numbered"> <tbody><tr> <td>Keyword</td> <td>1-79 bytes (character string)</td> </tr> <tr> <td>Null separator</td> <td>1 byte (null character)</td> </tr> <tr> <td>Compression method</td> <td>1 byte</td> </tr> <tr> <td>Compressed text datastream</td> <td>n bytes</td> </tr> </tbody></table> <p>The keyword and null character are the same as in the <a class="chunk" href="#11tEXt">tEXt</a> chunk. The keyword is not compressed. The compression method entry defines the compression method used. The only value defined in this International Standard is 0 (<a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-14">deflate</a> compression). Other values are reserved for future standardization. The compression method entry is followed by the compressed text datastream that makes up the remainder of the chunk. For compression method 0, this datastream is a <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-16">zlib</a> datastream with deflate compression (see <a href="#10CompressionOtherUses" class="sec-ref"><bdi class="secno">10.3 </bdi>Other uses of compression</a>). Decompression of this datastream yields Latin-1 text that is identical to the text that would be stored in an equivalent <a class="chunk" href="#11tEXt">tEXt</a> chunk.</p> </section> <section id="11iTXt"><div class="header-wrapper"><h5 id="x11-3-3-4-itxt-international-textual-data"><bdi class="secno">11.3.3.4 </bdi><span class="chunk">iTXt</span> International textual data</h5><a class="self-link" href="#11iTXt" aria-label="Permalink for Section 11.3.3.4"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">69 54 58 74</code></pre> <p>An <span class="chunk">iTXt</span> chunk contains:</p> <table id="iTXt-structure" class="simple numbered"> <tbody><tr> <td>Keyword</td> <td>1-79 bytes (character string)</td> </tr> <tr> <td>Null separator</td> <td>1 byte (null character)</td> </tr> <tr> <td>Compression flag</td> <td>1 byte</td> </tr> <tr> <td>Compression method</td> <td>1 byte</td> </tr> <tr> <td>Language tag</td> <td>0 or more bytes (character string)</td> </tr> <tr> <td>Null separator</td> <td>1 byte (null character)</td> </tr> <tr> <td>Translated keyword</td> <td>0 or more bytes</td> </tr> <tr> <td>Null separator</td> <td>1 byte (null character)</td> </tr> <tr> <td>Text</td> <td>0 or more bytes</td> </tr> </tbody></table> <p>The keyword is described in <a href="#11keywords" class="sec-ref"><bdi class="secno">11.3.3.1 </bdi>Keywords and text strings</a>.</p> <p>The compression flag is 0 for uncompressed text, 1 for compressed text. Only the text field may be compressed. The compression method entry defines the compression method used. The only compression method defined in this specification is 0 (<a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-17">zlib</a> datastream with <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-15">deflate</a> compression, see <a href="#10CompressionOtherUses" class="sec-ref"><bdi class="secno">10.3 </bdi>Other uses of compression</a>). For uncompressed text, encoders shall set the compression method to 0, and decoders shall ignore it.</p> <p>The language tag is a well-formed language tag defined by [<cite><a class="bibref" data-link-type="biblio" href="#bib-bcp47" title="Tags for Identifying Languages">BCP47</a></cite>]. Unlike the keyword, the language tag is case-insensitive. Subtags must appear in the <a href="https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry">IANA language subtag registry</a>. If the language tag is empty, the language is unspecified. Examples of language tags include: <code>en</code>, <code>en-GB</code>, <code>es-419</code>, <code>zh-Hans</code>, <code>zh-Hans-CN</code>, <code>tlh-Cyrl-AQ</code>, <code>ar-AE-u-nu-latn</code>, and <code>x-private</code>.</p> <p>The translated keyword and text both use the UTF-8 encoding [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc3629" title="UTF-8, a transformation format of ISO 10646">rfc3629</a></cite>], and neither shall contain a zero byte (null character). The text, unlike other textual data in this chunk, is not null-terminated; its length is derived from the chunk length.</p> <p>Line breaks should not appear in the translated keyword. In the text, a newline should be represented by a single linefeed character (hexadecimal 0A). The remaining control characters (01-09, 0B-1F, 7F-9F) are discouraged in both the translated keyword and text. In UTF-8 there is a difference between the characters 80-9F (which are discouraged) and the bytes 80-9F (which are often necessary).</p> <p>The translated keyword, if not empty, should contain a translation of the keyword into the language indicated by the language tag, and applications displaying the keyword should display the translated keyword in addition.</p> </section> </section> <section id="11addnlsiinfo"><div class="header-wrapper"><h4 id="x11-3-4-miscellaneous-information"><bdi class="secno">11.3.4 </bdi>Miscellaneous information</h4><a class="self-link" href="#11addnlsiinfo" aria-label="Permalink for Section 11.3.4"></a></div> <section id="11bKGD"><div class="header-wrapper"><h5 id="x11-3-4-1-bkgd-background-color"><bdi class="secno">11.3.4.1 </bdi><span class="chunk">bKGD</span> Background color</h5><a class="self-link" href="#11bKGD" aria-label="Permalink for Section 11.3.4.1"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">62 4B 47 44</code></pre> <p>The <span class="chunk">bKGD</span> chunk specifies a default background color to present the image against. If there is any other preferred background, either user-specified or part of a larger page (as in a browser), the <span class="chunk">bKGD</span> chunk should be ignored. The <span class="chunk">bKGD</span> chunk contains:</p> <table id="bKGD-structure" class="numbered simple"> <caption><a class="self-link" href="#bKGD-structure">Table <bdi class="tableno">22</bdi></a> <span class="table-title"> bKGD chunk contents </span></caption> <tbody><tr> <th colspan="2">Color types 0 and 4</th> </tr> <tr> <td>Greyscale</td> <td>2 bytes</td> </tr> <tr> <th colspan="2">Color types 2 and 6</th> </tr> <tr> <td>Red</td> <td>2 bytes</td> </tr> <tr> <td>Green</td> <td>2 bytes</td> </tr> <tr> <td>Blue</td> <td>2 bytes</td> </tr> <tr> <th colspan="2">Color type 3</th> </tr> <tr> <td>Palette index</td> <td>1 byte</td> </tr> </tbody></table> <p>For <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-28">color type</a> 3 (<a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-15">indexed-color</a>), the value is the palette index of the color to be used as background.</p> <p>For <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-29">color types</a> 0 and 4 (<a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-11">greyscale</a>, <a href="#dfn-greyscale-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-with-alpha-3">greyscale with alpha</a>), the value is the grey level to be used as background in the range 0 to (2<sup>bitdepth</sup>)-1. For <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-30">color types</a> 2 and 6 (<a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-13">truecolor</a>, <a href="#dfn-truecolor-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-truecolor-with-alpha-4">truecolor with alpha</a>), the values are the color to be used as background, given as RGB samples in the range 0 to (2<sup>bitdepth</sup>)-1. In each case, for consistency, two bytes per sample are used regardless of the image bit depth. If the image bit depth is less than 16, the least significant bits are used. Encoders should set the other bits to 0, and decoders must mask the other bits to 0 before the value is used.</p> </section> <section id="11hIST"><div class="header-wrapper"><h5 id="x11-3-4-2-hist-image-histogram"><bdi class="secno">11.3.4.2 </bdi><span class="chunk">hIST</span> Image histogram</h5><a class="self-link" href="#11hIST" aria-label="Permalink for Section 11.3.4.2"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">68 49 53 54</code></pre> <p>The <span class="chunk">hIST</span> chunk contains a series of two-byte unsigned integers:</p> <table id="hIST-structure" class="simple numbered"> <tbody><tr> <td>Frequency</td> <td>2 bytes (unsigned integer)</td> </tr> <tr> <td>...etc...</td> <td> </td> </tr> </tbody></table> <p>The <span class="chunk">hIST</span> chunk gives the approximate usage frequency of each color in the palette. A histogram chunk can appear only when a <a class="chunk" href="#11PLTE">PLTE</a> chunk appears. If a viewer is unable to provide all the colors listed in the palette, the histogram may help it decide how to choose a subset of the colors for display.</p> <p>There shall be exactly one entry for each entry in the <a class="chunk" href="#11PLTE">PLTE</a> chunk. Each entry is proportional to the fraction of pixels in the image that have that palette index; the exact scale factor is chosen by the encoder.</p> <p>Histogram entries are approximate, with the exception that a zero entry specifies that the corresponding palette entry is not used at all in the image. A histogram entry shall be nonzero if there are any pixels of that color.</p> <div class="note" role="note" id="issue-container-generatedID-18"><div role="heading" class="note-title marker" id="h-note-18" aria-level="6"><span>Note</span></div><p class="">NOTE When the palette is a suggested quantization of a <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-14">truecolor</a> image, the histogram is necessarily approximate, since a decoder may map pixels to palette entries differently than the encoder did. In this situation, zero entries should not normally appear, because any entry might be used.</p></div> </section> <section id="11pHYs"><div class="header-wrapper"><h5 id="x11-3-4-3-phys-physical-pixel-dimensions"><bdi class="secno">11.3.4.3 </bdi><span class="chunk">pHYs</span> Physical pixel dimensions</h5><a class="self-link" href="#11pHYs" aria-label="Permalink for Section 11.3.4.3"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">70 48 59 73</code></pre> <p>The <span class="chunk">pHYs</span> chunk specifies the intended pixel size or aspect ratio for display of the image. It contains:</p> <table id="pHYs-structure" class="numbered simple"> <caption><a class="self-link" href="#pHYs-structure">Table <bdi class="tableno">23</bdi></a> <span class="table-title"> pHYs chunk contents </span></caption> <tbody><tr> <th>Name</th> <th>Size</th> </tr> <tr> <td>Pixels per unit, X axis</td> <td> 4 bytes (<a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-8">PNG four-byte unsigned integer</a>) </td> </tr> <tr> <td>Pixels per unit, Y axis</td> <td> 4 bytes (<a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-9">PNG four-byte unsigned integer</a>) </td> </tr> <tr> <td>Unit specifier</td> <td>1 byte</td> </tr> </tbody></table> <p>The following values are defined for the unit specifier:</p> <table id="unit-specifiers" class="numbered simple"> <caption><a class="self-link" href="#unit-specifiers">Table <bdi class="tableno">24</bdi></a> <span class="table-title"> Unit specifier values </span></caption> <tbody><tr> <th>Value</th> <th>Description</th> </tr> <tr> <td>0</td> <td>unit is unknown</td> </tr> <tr> <td>1</td> <td>unit is the metre</td> </tr> </tbody></table> <p>When the unit specifier is 0, the <span class="chunk">pHYs</span> chunk defines pixel aspect ratio only; the actual size of the pixels remains unspecified.</p> <p>If the <span class="chunk">pHYs</span> chunk is not present, pixels are assumed to be square, and the physical size of each pixel is unspecified.</p> </section> <section id="11sPLT"><div class="header-wrapper"><h5 id="x11-3-4-4-splt-suggested-palette"><bdi class="secno">11.3.4.4 </bdi><span class="chunk">sPLT</span> Suggested palette</h5><a class="self-link" href="#11sPLT" aria-label="Permalink for Section 11.3.4.4"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">73 50 4C 54</code></pre> <p>The <span class="chunk">sPLT</span> chunk contains:</p> <table id="sPLT-structure" class="numbered simple"> <caption><a class="self-link" href="#sPLT-structure">Table <bdi class="tableno">25</bdi></a> <span class="table-title"> sPLT chunk contents </span></caption> <tbody><tr> <th>Name</th> <th>Size</th> </tr> <tr> <td>Palette name</td> <td>1-79 bytes (character string)</td> </tr> <tr> <td>Null separator</td> <td>1 byte (null character)</td> </tr> <tr> <td>Sample depth</td> <td>1 byte</td> </tr> <tr> <td>Red</td> <td>1 or 2 bytes</td> </tr> <tr> <td>Green</td> <td>1 or 2 bytes</td> </tr> <tr> <td>Blue</td> <td>1 or 2 bytes</td> </tr> <tr> <td>Alpha</td> <td>1 or 2 bytes</td> </tr> <tr> <td>Frequency</td> <td>2 bytes</td> </tr> <tr> <td>...etc...</td> <td> </td> </tr> </tbody></table> <p>Each palette entry is six bytes or ten bytes containing five unsigned integers (red, blue, green, alpha, and frequency).</p> <p>There may be any number of entries. A PNG decoder determines the number of entries from the length of the chunk remaining after the sample depth byte. This shall be divisible by 6 if the <span class="chunk">sPLT</span> sample depth is 8, or by 10 if the <span class="chunk">sPLT</span> sample depth is 16. Entries shall appear in decreasing order of frequency. There is no requirement that the entries all be used by the image, nor that they all be different.</p> <p>The palette name can be any convenient name for referring to the palette (for example "256 color including Macintosh default", "256 color including Windows-3.1 default", "Optimal 512"). The palette name may aid the choice of the appropriate suggested palette when more than one appears in a PNG datastream.</p> <p>The palette name is case-sensitive, and subject to the same restrictions as the keyword parameter for the <a class="chunk" href="#11tEXt">tEXt</a> chunk. Palette names shall contain only printable Latin-1 characters and spaces (only code points 0x20-7E and 0xA1-FF are allowed). Leading, trailing, and consecutive spaces are not permitted.</p> <p>The <span class="chunk">sPLT</span> sample depth shall be 8 or 16.</p> <p>The red, green, blue, and alpha samples are either one or two bytes each, depending on the <span class="chunk">sPLT</span> sample depth, regardless of the image bit depth. The color samples are not premultiplied by alpha, nor are they precomposited against any background. An alpha value of 0 means fully transparent. An alpha value of 255 (when the <span class="chunk">sPLT</span> sample depth is 8) or 65535 (when the <span class="chunk">sPLT</span> sample depth is 16) means fully opaque. The <span class="chunk">sPLT</span> chunk may appear for any <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-31">color type</a>. Entries in <span class="chunk">sPLT</span> use the same <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-6">gamma value</a> and <a href="#dfn-chromaticity" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-chromaticity-4">chromaticity</a> values as the PNG image, but may fall outside the range of values used in the color space of the PNG image; for example, in a <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-12">greyscale</a> PNG image, each <span class="chunk">sPLT</span> entry would typically have equal red, green, and blue values, but this is not required. Similarly, <span class="chunk">sPLT</span> entries can have non-opaque alpha values even when the PNG image does not use transparency.</p> <p>Each frequency value is proportional to the fraction of the pixels in the image for which that palette entry is the closest match in RGBA space, before the image has been <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-5">composited</a> against any background. The exact scale factor is chosen by the PNG encoder; it is recommended that the resulting range of individual values reasonably fills the range 0 to 65535. A PNG encoder may artificially inflate the frequencies for colors considered to be "important", for example the colors used in a logo or the facial features of a portrait. Zero is a valid frequency meaning that the color is "least important" or that it is rarely, if ever, used. When all the frequencies are zero, they are meaningless, that is to say, nothing may be inferred about the actual frequencies with which the colors appear in the PNG image.</p> <p>Multiple <span class="chunk">sPLT</span> chunks are permitted, but each shall have a different palette name.</p> </section> <section id="eXIf"><div class="header-wrapper"><h5 id="x11-3-4-5-exif-exchangeable-image-file-exif-profile"><bdi class="secno">11.3.4.5 </bdi><span class="chunk">eXIf</span> Exchangeable Image File (Exif) Profile</h5><a class="self-link" href="#eXIf" aria-label="Permalink for Section 11.3.4.5"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">65 58 49 66</code></pre> <p>The data segment of the <span class="chunk">eXIf</span> chunk contains an Exif profile in the format specified in "4.7.2 Interoperability Structure of APP1 in Compressed Data" of [<cite><a class="bibref" data-link-type="biblio" href="#bib-cipa-dc-008" title="Exchangeable image file format for digital still cameras: Exif Version 2.32">CIPA-DC-008</a></cite>] except that the JPEG APP1 marker, length, and the "Exif ID code" described in 4.7.2(C), i.e., "Exif", NULL, and padding byte, are not included.</p> <p>The <span class="chunk">eXIf</span> chunk size is constrained only by the maximum of 2<sup>31</sup>-1 bytes imposed by the PNG specification. Only one <span class="chunk">eXIf</span> chunk is allowed in a PNG datastream.</p> <p>The <span class="chunk">eXIf</span> chunk contains metadata concerning the original <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-13">image data</a>. If the image has been edited subsequent to creation of the Exif profile, this data might no longer apply to the PNG <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-14">image data</a>. It is recommended that unless a decoder has independent knowledge of the validity of the Exif data, the data should be considered to be of historical value only. It is beyond the scope of this specification to resolve potential conflicts between data in the eXIf chunk and in other PNG chunks.</p> <section id="exif-general-recommendations"><div class="header-wrapper"><h6 id="x11-3-4-5-1-exif-general-recommendations"><bdi class="secno">11.3.4.5.1 </bdi><span class="chunk">eXIf</span> General Recommendations</h6><a class="self-link" href="#exif-general-recommendations" aria-label="Permalink for Section 11.3.4.5.1"></a></div> <p>While the PNG specification allows the chunk size to be as large as 2<sup>31</sup>-1 bytes, application authors should be aware that, if the Exif profile is going to be written to a JPEG [<cite><a class="bibref" data-link-type="biblio" href="#bib-jpeg" title="JPEG File Interchange Format">JPEG</a></cite>] datastream, the total length of the <span class="chunk">eXIf</span> chunk data may need to be adjusted to not exceed 2<sup>16</sup>-9 bytes, so it can fit into a JPEG APP1 marker (Exif) segment.</p> </section> <section id="exif-recommendations-for-decoders"><div class="header-wrapper"><h6 id="x11-3-4-5-2-exif-recommendations-for-decoders"><bdi class="secno">11.3.4.5.2 </bdi><span class="chunk">eXIf</span> Recommendations for Decoders</h6><a class="self-link" href="#exif-recommendations-for-decoders" aria-label="Permalink for Section 11.3.4.5.2"></a></div> <p>The first two bytes of data are either "II" for little-endian (Intel) or "MM" for big-endian (Motorola) byte order. Decoders should check the first four bytes to ensure that they have the following hexadecimal values:</p> <pre aria-busy="false"><code class="hljs javascript"><span class="hljs-number">49</span> <span class="hljs-number">49</span> 2A <span class="hljs-number">00</span> (<span class="hljs-variable constant_">ASCII</span> <span class="hljs-string">"II"</span>, <span class="hljs-number">16</span>-bit little-endian integer <span class="hljs-number">42</span>)</code></pre> <p>or</p> <pre aria-busy="false"><code class="hljs javascript">4D 4D <span class="hljs-number">00</span> 2A (<span class="hljs-variable constant_">ASCII</span> <span class="hljs-string">"MM"</span>, <span class="hljs-number">16</span>-bit big-endian integer <span class="hljs-number">42</span>)</code></pre> <p>All other values are reserved for possible future definition.</p> </section> <section id="exif-recommendations-for-encoders"><div class="header-wrapper"><h6 id="x11-3-4-5-3-exif-recommendations-for-encoders"><bdi class="secno">11.3.4.5.3 </bdi><span class="chunk">eXIf</span> Recommendations for Encoders</h6><a class="self-link" href="#exif-recommendations-for-encoders" aria-label="Permalink for Section 11.3.4.5.3"></a></div> <p>Image editing applications should consider Paragraph E.3 of the Exif Specification [<cite><a class="bibref" data-link-type="biblio" href="#bib-cipa-dc-008" title="Exchangeable image file format for digital still cameras: Exif Version 2.32">CIPA-DC-008</a></cite>], which discusses requirements for updating Exif data when the image is changed. Encoders should follow those requirements, but decoders should not assume that it has been accomplished.</p> <p>While encoders may choose to update them, there is no expectation that any thumbnails present in the Exif profile have (or have not) been updated if the main image was changed.</p> </section> </section> </section> <section id="11timestampinfo"><div class="header-wrapper"><h4 id="x11-3-5-time-stamp-information"><bdi class="secno">11.3.5 </bdi>Time stamp information</h4><a class="self-link" href="#11timestampinfo" aria-label="Permalink for Section 11.3.5"></a></div> <section id="11tIME"><div class="header-wrapper"><h5 id="x11-3-5-1-time-image-last-modification-time"><bdi class="secno">11.3.5.1 </bdi><span class="chunk">tIME</span> Image last-modification time</h5><a class="self-link" href="#11tIME" aria-label="Permalink for Section 11.3.5.1"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">74 49 4D 45</code></pre> <p>The <span class="chunk">tIME</span> chunk gives the time of the last image modification (<strong>not</strong> the time of initial image creation). It contains:</p> <table id="tIME-structure" class="numbered simple"> <caption><a class="self-link" href="#tIME-structure">Table <bdi class="tableno">26</bdi></a> <span class="table-title"> tIME chunk contents </span></caption> <tbody><tr> <th>Name</th> <th>Size</th> </tr> <tr> <td>Year</td> <td>2 bytes (complete; for example, 1995, <strong>not</strong> 95)</td> </tr> <tr> <td>Month</td> <td>1 byte (1-12)</td> </tr> <tr> <td>Day</td> <td>1 byte (1-31)</td> </tr> <tr> <td>Hour</td> <td>1 byte (0-23)</td> </tr> <tr> <td>Minute</td> <td>1 byte (0-59)</td> </tr> <tr> <td>Second</td> <td>1 byte (0-60) (to allow for leap seconds)</td> </tr> </tbody></table> <p>Universal Time (UTC) should be specified rather than local time.</p> <p>The <span class="chunk">tIME</span> chunk is intended for use as an automatically-applied time stamp that is updated whenever the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-15">image data</a> are changed.</p> </section> </section> <section id="animation-information"><div class="header-wrapper"><h4 id="x11-3-6-animation-information"><bdi class="secno">11.3.6 </bdi>Animation information</h4><a class="self-link" href="#animation-information" aria-label="Permalink for Section 11.3.6"></a></div> <section id="acTL-chunk"><div class="header-wrapper"><h5 id="x11-3-6-1-actl-animation-control-chunk"><bdi class="secno">11.3.6.1 </bdi><span class="chunk">acTL</span> Animation Control Chunk</h5><a class="self-link" href="#acTL-chunk" aria-label="Permalink for Section 11.3.6.1"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">61 63 54 4C</code></pre> <p>The <span class="chunk">acTL</span> chunk declares that this is an animated PNG image, gives the number of frames, and the number of times to loop. It contains:</p> <table id="acTL-structure" class="simple numbered"> <tbody><tr> <td><code>num_frames</code></td> <td>4 bytes</td> </tr> <tr> <td><code>num_plays</code></td> <td>4 bytes</td> </tr> </tbody></table> <p>Each value is encoded as a <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-10">PNG four-byte unsigned integer</a>.</p> <p><code>num_frames</code> indicates the total number of frames in the animation. This must equal the number of <a class="chunk" href="#fcTL-chunk">fcTL</a> chunks. 0 is not a valid value. 1 is a valid value, for a single-frame PNG. If this value does not equal the actual number of frames it should be treated as an error.</p> <p><code>num_plays</code> indicates the number of times that this animation should play; if it is 0, the animation should play indefinitely. If nonzero, the animation should come to rest on the final frame at the end of the last play.</p> <p>The <span class="chunk">acTL</span> chunk must appear before the first <a class="chunk" href="#11IDAT">IDAT</a> chunk within a valid PNG stream.</p> <div class="note" role="note" id="issue-container-generatedID-19"><div role="heading" class="note-title marker" id="h-note-19" aria-level="6"><span>Note</span></div><p class="">For Web compatibility, due to the long time between the development and deployment of this chunk and it's incorporation into the PNG specification, this chunk name is exceptionally defined as if it were a private chunk.</p></div> </section> <section id="fcTL-chunk"><div class="header-wrapper"><h5 id="x11-3-6-2-fctl-frame-control-chunk"><bdi class="secno">11.3.6.2 </bdi><span class="chunk">fcTL</span> Frame Control Chunk</h5><a class="self-link" href="#fcTL-chunk" aria-label="Permalink for Section 11.3.6.2"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">66 63 54 4C</code></pre> <p>The <span class="chunk">fcTL</span> chunk defines the dimensions, position, delay and disposal of an individual frame. Exactly one <span class="chunk">fcTL</span> chunk chunk is required for each frame. It contains:</p> <table id="fcTL-structure" class="numbered simple"> <caption><a class="self-link" href="#fcTL-structure">Table <bdi class="tableno">27</bdi></a> <span class="table-title"> fcTL chunk contents </span></caption> <tbody><tr> <th>Name</th> <th>Size</th> </tr> <tr> <td><code>sequence_number</code></td> <td>4 bytes</td> </tr> <tr> <td><code>width</code></td> <td>4 bytes</td> </tr> <tr> <td><code>height</code></td> <td>4 bytes</td> </tr> <tr> <td><code>x_offset</code></td> <td>4 bytes</td> </tr> <tr> <td><code>y_offset</code></td> <td>4 bytes</td> </tr> <tr> <td><code>delay_num</code></td> <td>2 bytes</td> </tr> <tr> <td><code>delay_den</code></td> <td>2 bytes</td> </tr> <tr> <td><code>dispose_op</code></td> <td>1 byte</td> </tr> <tr> <td><code>blend_op</code></td> <td>1 byte</td> </tr> </tbody></table> <p><code>sequence_number</code> defines the <a href="#4Concepts.APNGSequence">sequence number</a> of the animation chunk, starting from 0. It is encoded as a <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-11">PNG four-byte unsigned integer</a>.</p> <p><code>width</code> and <code>height</code> define the width and height of the following frame. They are encoded as <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-12">PNG four-byte unsigned integers</a>. They must be greater than zero.</p> <p><code>x_offset</code> and <code>y_offset</code> define the x and y position of the following frame. They are encoded as <a href="#dfn-png-four-byte-unsigned-integer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-four-byte-unsigned-integer-13">PNG four-byte unsigned integers</a>. Zero is a valid value.</p> <p>The frame must be rendered within the region defined by <code>x_offset</code>, <code>y_offset</code>, <code>width</code>, and <code>height</code>. This region may not fall outside of the default image; thus <code>x_offset</code> plus <code>width</code> must not be greater than the <a class="chunk" href="#11IHDR">IHDR</a> width; similarly <code>y_offset</code> plus <code>height</code> must not be greater than the <a class="chunk" href="#11IHDR">IHDR</a> height.</p> <p><code>delay_num</code> and <code>delay_den</code> define the numerator and denominator of the delay fraction; indicating the time to display the current frame, in seconds. If the denominator is 0, it is to be treated as if it were 100 (that is, <code>delay_num</code> then specifies 1/100ths of a second). If the the value of the numerator is 0 the decoder should render the next frame as quickly as possible, though viewers may impose a reasonable lower bound. They are encoded as two-byte unsigned integers.</p> <p>Frame timings should be independent of the time required for decoding and display of each frame, so that animations will run at the same rate regardless of the performance of the decoder implementation.</p> <p><code>dispose_op</code> defines the type of frame area disposal to be done after rendering this frame; in other words, it specifies how the output buffer should be changed at the end of the delay (before rendering the next frame). It is encoded as a one-byte unsigned integer.</p> <p>Valid values for <code>dispose_op</code> are:</p> <table id="dispose-op-values" class="simple numbered"> <tbody><tr> <td>0</td> <td><code>APNG_DISPOSE_OP_NONE</code></td> </tr> <tr> <td>1</td> <td><code>APNG_DISPOSE_OP_BACKGROUND</code></td> </tr> <tr> <td>2</td> <td><code>APNG_DISPOSE_OP_PREVIOUS</code></td> </tr> </tbody></table> <dl> <dt><code>APNG_DISPOSE_OP_NONE</code></dt> <dd>no disposal is done on this frame before rendering the next; the contents of the output buffer are left as is.</dd> <dt><code>APNG_DISPOSE_OP_BACKGROUND</code></dt> <dd>the frame's region of the output buffer is to be cleared to fully transparent black before rendering the next frame.</dd> <dt><code>APNG_DISPOSE_OP_PREVIOUS</code></dt> <dd>the frame's region of the output buffer is to be reverted to the previous contents before rendering the next frame.</dd> </dl> <p>If the first <span class="chunk">fcTL</span> chunk uses a <code>dispose_op</code> of <code>APNG_DISPOSE_OP_PREVIOUS</code> it should be treated as <code>APNG_DISPOSE_OP_BACKGROUND</code>.</p> <p><code>blend_op</code> specifies whether the frame is to be alpha blended into the current output buffer content, or whether it should completely replace its region in the output buffer. It is encoded as a one-byte unsigned integer.</p> <p>Valid values for <code>blend_op</code> are:</p> <table id="blend-op-values" class="simple numbered"> <tbody><tr> <td>0</td> <td><code>APNG_BLEND_OP_SOURCE</code></td> </tr> <tr> <td>1</td> <td><code>APNG_BLEND_OP_OVER</code></td> </tr> </tbody></table> <p>If <code>blend_op</code> is <code>APNG_BLEND_OP_SOURCE</code> all color components of the frame, including alpha, overwrite the current contents of the frame's output buffer region. If <code>blend_op</code> is <code>APNG_BLEND_OP_OVER</code> the frame should be <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-6">composited</a> onto the output buffer based on its alpha, using a simple OVER operation as described in <a href="#13Alpha-channel-processing">Alpha Channel Processing</a>. Note that the second variation of the sample code is applicable.</p> <p>Note that for the first frame, the two blend modes are functionally equivalent due to the clearing of the output buffer at the beginning of each play.</p> <p>The <span class="chunk">fcTL</span> chunk corresponding to the default image, if it exists, has these restrictions:</p> <ul> <li>The <code>x_offset</code> and <code>y_offset</code> fields must be 0.</li> <li>The <code>width</code> and <code>height</code> fields must equal the corresponding fields from the <a class="chunk" href="#11IHDR">IHDR</a> chunk. </li> </ul> <p>As noted earlier, the output buffer must be completely initialized to fully transparent black at the beginning of each play. This is to ensure that each play of the animation will be identical. Decoders are free to avoid an explicit clear step as long as the result is guaranteed to be identical. For example, if the default image is included in the animation, and uses a <code>blend_op</code> of <code>APNG_BLEND_OP_SOURCE</code>, clearing is not necessary because the entire output buffer will be overwritten.</p> <div class="note" role="note" id="issue-container-generatedID-20"><div role="heading" class="note-title marker" id="h-note-20" aria-level="6"><span>Note</span></div><p class="">For Web compatibility, due to the long time between the development and deployment of this chunk and it's incorporation into the PNG specification, this chunk name is exceptionally defined as if it were a private chunk.</p></div> </section> <section id="fdAT-chunk"><div class="header-wrapper"><h5 id="x11-3-6-3-fdat-frame-data-chunk"><bdi class="secno">11.3.6.3 </bdi><span class="chunk">fdAT</span> Frame Data Chunk</h5><a class="self-link" href="#fdAT-chunk" aria-label="Permalink for Section 11.3.6.3"></a></div> <p>The four-byte chunk type field contains the hexadecimal values</p> <pre aria-busy="false"><code class="hljs">66 64 41 54</code></pre> <p>The <span class="chunk">fdAT</span> chunk serves the same purpose for animations as the <a class="chunk" href="#11IDAT">IDAT</a> chunks do for static images; the set of <span class="chunk">fdAT</span> chunks contains the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-16">image data</a> for all frames (or, for animations which include the <a href="#dfn-static-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-static-image-7">static image</a> as first frame, for all frames after the first one). It contains:</p> <table id="fdAT-structure" class="numbered simple"> <caption><a class="self-link" href="#fdAT-structure">Table <bdi class="tableno">28</bdi></a> <span class="table-title"> fdAT chunk contents </span></caption> <tbody><tr> <th>Name</th> <th>Size</th> </tr> <tr> <td><code>sequence_number</code></td> <td>4 bytes</td> </tr> <tr> <td><code>frame_data</code></td> <td><i>n</i> bytes</td> </tr> </tbody></table> <p>At least one <span class="chunk">fdAT</span> chunk is required for each frame, except for the first frame, if that frame is represented by an <a class="chunk" href="#11IDAT">IDAT</a> chunk.</p> <p>The compressed datastream for each frame is then the concatenation, in ascending <a href="#4Concepts.APNGSequence">sequence number</a> order, of the contents of the <code>frame_data</code> fields of all the <span class="chunk">fdAT</span> chunks within a frame.</p> <p>Because of the sequence number, <span class="chunk">fdAT</span> chunks <a href="#zero-length-data">may not be of zero length</a>); however the <code>frame_data</code> fields may be of zero length. When decompressed, the datastream is the complete pixel data of a PNG image, including the filter byte at the beginning of each scanline, similar to the uncompressed data of all the <a class="chunk" href="#11IDAT">IDAT</a> chunks. It utilizes the same bit depth, <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-32">color type</a>, compression method, <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-12">filter method</a>, interlace method, and palette (if any) as the <a href="#dfn-static-image" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-static-image-8">static image</a>.</p> <p>Each frame inherits every property specified by any critical or ancillary chunks <em>before</em> the first <a class="chunk" href="#11IDAT">IDAT</a> chunk in the file, except the width and height, which come from the <span class="chunk">fcTL</span> chunk.</p> <p>If the PNG <a class="chunk" href="#11pHYs">pHYs</a> chunk is present, the <abbr title="Animated PNG">APNG</abbr> images and their <code>x_offset</code> and <code>y_offset</code> values must be scaled in the same way as the main image. Conceptually, such scaling occurs while mapping the output buffer onto the <a href="#dfn-canvas" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-canvas-3">canvas</a>.</p> <div class="note" role="note" id="issue-container-generatedID-21"><div role="heading" class="note-title marker" id="h-note-21" aria-level="6"><span>Note</span></div><p class="">For Web compatibility, due to the long time between the development and deployment of this chunk and it's incorporation into the PNG specification, this chunk name is exceptionally defined as if it were a private chunk.</p></div> </section> </section> </section> </section> <section id="12Encoders"><div class="header-wrapper"><h2 id="x12-png-encoders"><bdi class="secno">12. </bdi>PNG Encoders</h2><a class="self-link" href="#12Encoders" aria-label="Permalink for Section 12."></a></div> <section class="introductory" id="12Introduction"><div class="header-wrapper"><h3 id="introduction-8">Introduction</h3><a class="self-link" href="#12Introduction" aria-label="Permalink for this Section"></a></div> <p>This clause gives requirements and recommendations for encoder behavior. A PNG encoder shall produce a PNG datastream from a PNG image that conforms to the format specified in the preceding clauses. Best results will usually be achieved by following the additional recommendations given here.</p> </section> <section id="12Encoder-gamma-handling"><div class="header-wrapper"><h3 id="x12-1-encoder-gamma-handling"><bdi class="secno">12.1 </bdi>Encoder gamma handling</h3><a class="self-link" href="#12Encoder-gamma-handling" aria-label="Permalink for Section 12.1"></a></div> <p>See <a href="#C-GammaAppendix" class="sec-ref"><bdi class="secno">C. </bdi>Gamma and chromaticity</a> for a brief introduction to <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-4">gamma</a> issues.</p> <p>PNG encoders capable of full color management will perform more sophisticated calculations than those described here and may choose to use the <a class="chunk" href="#11iCCP">iCCP</a> chunk. If it is known that the image samples conform to the sRGB specification [<cite><a class="bibref" data-link-type="biblio" href="#bib-srgb" title="Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB">SRGB</a></cite>], encoders are strongly encouraged to write the <a class="chunk" href="#srgb-standard-colour-space">sRGB</a> chunk without performing additional <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-5">gamma</a> handling. In both cases it is recommended that an appropriate <a class="chunk" href="#11gAMA">gAMA</a> chunk be generated for use by PNG decoders that do not recognize the <a class="chunk" href="#11iCCP">iCCP</a> or <a class="chunk" href="#srgb-standard-colour-space">sRGB</a> chunks.</p> <p>A PNG encoder has to determine:</p> <ol> <li>what value to write in the <a class="chunk" href="#11gAMA">gAMA</a> chunk; </li> <li>how to transform the provided image samples into the values to be written in the PNG datastream.</li> </ol> <p>The value to write in the <a class="chunk" href="#11gAMA">gAMA</a> chunk is that value which causes a PNG decoder to behave in the desired way. See <a class="Href sec-ref" href="#13Decoder-gamma-handling"><bdi class="secno">13.13 </bdi>Decoder gamma handling</a>.</p> <p>The transform to be applied depends on the nature of the image samples and their precision. If the samples represent light intensity in floating-point or high precision integer form (perhaps from a computer graphics renderer), the encoder may perform <dfn id="dfn-gamma-encoding" tabindex="0" aria-haspopup="dialog" data-dfn-type="dfn">gamma encoding</dfn> (applying a power function with exponent less than 1) before quantizing the data to integer values for inclusion in the PNG datastream. This results in fewer banding artifacts at a given sample depth, or allows smaller samples while retaining the same visual quality. An intensity level expressed as a floating-point value in the range 0 to 1 can be converted to a datastream image sample by:</p> <p><code>integer_sample = floor((2<sup>sampledepth</sup>-1) * intensity<sup>encoding_exponent</sup> + 0.5)</code> </p> <p>If the intensity in the equation is the desired output intensity, the encoding exponent is the <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-7">gamma value</a> to be used in the <a class="chunk" href="#11gAMA">gAMA</a> chunk.</p> <p>If the intensity available to the PNG encoder is the original scene intensity, another transformation may be needed. There is sometimes a requirement for the displayed image to have higher contrast than the original source image. This corresponds to an end-to-end <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-12">transfer function</a> from original scene to display output with an exponent greater than 1. In this case:</p> <pre aria-busy="false"><code class="hljs abnf"><span class="hljs-attribute">gamma</span> <span class="hljs-operator">=</span> encoding_exponent/end_to_end_exponent</code></pre> <p>If it is not known whether the conditions under which the original image was captured or calculated warrant such a contrast change, it may be assumed that the display intensities are proportional to original scene intensities, i.e. the end-to-end exponent is 1 and hence:</p> <pre aria-busy="false"><code class="hljs abnf"><span class="hljs-attribute">gamma</span> <span class="hljs-operator">=</span> encoding_exponent</code></pre> <p>If the image is being written to a datastream only, the encoder is free to choose the encoding exponent. Choosing a value that causes the <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-8">gamma value</a> in the <a class="chunk" href="#11gAMA">gAMA</a> chunk to be 1/2.2 is often a reasonable choice because it minimizes the work for a PNG decoder displaying on a typical video monitor.</p> <p>Some image renderers may simultaneously write the image to a PNG datastream and display it on-screen. The displayed pixels should be <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-6">gamma</a> corrected for the display system and viewing conditions in use, so that the user sees a proper representation of the intended scene.</p> <p>If the renderer wants to write the displayed sample values to the PNG datastream, avoiding a separate <a href="#dfn-gamma-encoding" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-encoding-1">gamma encoding</a> step for the datastream, the renderer should approximate the <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-13">transfer function</a> of the display system by a power function, and write the reciprocal of the exponent into the <a class="chunk" href="#11gAMA">gAMA</a> chunk. This will allow a PNG decoder to reproduce what was displayed on screen for the originator during rendering.</p> <p>However, it is equally reasonable for a renderer to compute displayed pixels appropriate for the display device, and to perform separate <a href="#dfn-gamma-encoding" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-encoding-2">gamma encoding</a> for data storage and transmission, arranging to have a value in the <a class="chunk" href="#11gAMA">gAMA</a> chunk more appropriate to the future use of the image.</p> <p>Computer graphics renderers often do not perform <a href="#dfn-gamma-encoding" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-encoding-3">gamma encoding</a>, instead making sample values directly proportional to scene light intensity. If the PNG encoder receives sample values that have already been quantized into integer values, there is no point in doing <a href="#dfn-gamma-encoding" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-encoding-4">gamma encoding</a> on them; that would just result in further loss of information. The encoder should just write the sample values to the PNG datastream. This does not imply that the <a class="chunk" href="#11gAMA">gAMA</a> chunk should contain a <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-9">gamma value</a> of 1.0 because the desired end-to-end <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-14">transfer function</a> from scene intensity to display output intensity is not necessarily linear. However, the desired <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-10">gamma value</a> is probably not far from 1.0. It may depend on whether the scene being rendered is a daylight scene or an indoor scene, etc.</p> <p>When the sample values come directly from a piece of hardware, the correct <a class="chunk" href="#11gAMA">gAMA</a> value can, in principle, be inferred from the <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-15">transfer function</a> of the hardware and lighting conditions of the scene. In the case of video digitizers ("frame grabbers"), the samples are probably in the sRGB color space, because the sRGB specification was designed to be compatible with modern video standards. Image scanners are less predictable. Their output samples may be proportional to the input light intensity since CCD sensors themselves are linear, or the scanner hardware may have already applied a power function designed to compensate for dot gain in subsequent printing (an exponent of about 0.57), or the scanner may have corrected the samples for display on a monitor. It may be necessary to refer to the scanner's manual or to scan a calibrated target in order to determine the characteristics of a particular scanner. It should be remembered that <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-7">gamma</a> relates samples to desired display output, not to scanner input.</p> <p>Datastream format converters generally should not attempt to convert supplied images to a different <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-8">gamma</a>. The data should be stored in the PNG datastream without conversion, and the <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-11">gamma value</a> should be deduced from information in the source datastream if possible. <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-9">Gamma</a> alteration at datastream conversion time causes re-quantization of the set of intensity levels that are represented, introducing further roundoff error with little benefit. It is almost always better to just copy the sample values intact from the input to the output file.</p> <p>If the source datastream describes the <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-10">gamma</a> characteristics of the image, a datastream converter is strongly encouraged to write a <a class="chunk" href="#11gAMA">gAMA</a> chunk. Some datastream formats specify the display exponent (the exponent of the function which maps image samples to display output rather than the other direction). If the source file's <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-12">gamma value</a> is greater than 1.0, it is probably a display exponent, and the reciprocal of this value should be used for the PNG <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-13">gamma value</a>. If the source file format records the relationship between image samples and a quantity other than display output, it will be more complex than this to deduce the PNG <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-14">gamma value</a>.</p> <p>If a PNG encoder or datastream converter knows that the image has been displayed satisfactorily using a display system whose <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-16">transfer function</a> can be approximated by a power function with exponent <var>display_exponent</var>, the image can be marked as having the <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-15">gamma value</a>:</p> <pre aria-busy="false"><code class="hljs abnf"><span class="hljs-attribute">gamma</span> <span class="hljs-operator">=</span> <span class="hljs-number">1</span>/display_exponent</code></pre> <p>It is better to write a <a class="chunk" href="#11gAMA">gAMA</a> chunk with a value that is approximately correct than to omit the chunk and force PNG decoders to guess an approximate <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-16">gamma value</a>. If a PNG encoder is unable to infer the <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-17">gamma value</a>, it is preferable to omit the <a class="chunk" href="#11gAMA">gAMA</a> chunk. If a guess has to be made this should be left to the PNG decoder.</p> <p><a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-11">gamma</a> does not apply to alpha samples; alpha is always represented linearly.</p> <p>See also <a href="#13Decoder-gamma-handling" class="sec-ref"><bdi class="secno">13.13 </bdi>Decoder gamma handling</a>.</p> </section> <section id="12Encoder-colour-handling"><div class="header-wrapper"><h3 id="x12-2-encoder-color-handling"><bdi class="secno">12.2 </bdi>Encoder color handling</h3><a class="self-link" href="#12Encoder-colour-handling" aria-label="Permalink for Section 12.2"></a></div> <p>See <a href="#C-GammaAppendix" class="sec-ref"><bdi class="secno">C. </bdi>Gamma and chromaticity</a> for references to color issues.</p> <p>PNG encoders capable of full color management will perform more sophisticated calculations than those described here and may choose to use the <a class="chunk" href="#11iCCP">iCCP</a> chunk. If it is known that the image samples conform to the sRGB specification [<cite><a class="bibref" data-link-type="biblio" href="#bib-srgb" title="Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB">SRGB</a></cite>], PNG encoders are strongly encouraged to use the <a class="chunk" href="#srgb-standard-colour-space">sRGB</a> chunk.</p> <p>If it is possible for the encoder to determine the chromaticities of the source display primaries, or to make a strong guess based on the origin of the image, or the hardware running it, the encoder is strongly encouraged to output the <a class="chunk" href="#11cHRM">cHRM</a> chunk. If this is done, the <a class="chunk" href="#11gAMA">gAMA</a> chunk should also be written; decoders can do little with a <a class="chunk" href="#11cHRM">cHRM</a> chunk if the <a class="chunk" href="#11gAMA">gAMA</a> chunk is missing.</p> <p>There are a number of recommendations and standards for primaries and <a href="#dfn-white-point" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-white-point-4">white points</a>, some of which are linked to particular technologies, for example the CCIR 709 standard [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.709" title="ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange">ITU-R-BT.709</a></cite>] and the SMPTE-C standard [<cite><a class="bibref" data-link-type="biblio" href="#bib-smpte-170m" title="Television — Composite Analog Video Signal — NTSC for Studio Applications">SMPTE-170M</a></cite>].</p> <p>There are three cases that need to be considered:</p> <ol> <li>the encoder is part of the generation system;</li> <li>the source image is captured by a camera or scanner;</li> <li>the PNG datastream was generated by translation from some other format.</li> </ol> <p>In the case of hand-drawn or digitally edited images, it is necessary to determine what monitor they were viewed on when being produced. Many image editing programs allow the type of monitor being used to be specified. This is often because they are working in some device-independent space internally. Such programs have enough information to write valid <a class="chunk" href="#11cHRM">cHRM</a> and <a class="chunk" href="#11gAMA">gAMA</a> chunks, and are strongly encouraged to do so automatically.</p> <p>If the encoder is compiled as a portion of a computer image renderer that performs full-spectral rendering, the monitor values that were used to convert from the internal device-independent color space to RGB should be written into the <a class="chunk" href="#11cHRM">cHRM</a> chunk. Any colors that are outside the gamut of the chosen RGB device should be mapped to be within the gamut; PNG does not store out-of-gamut colors.</p> <p>If the computer image renderer performs calculations directly in device-dependent RGB space, a <a class="chunk" href="#11cHRM">cHRM</a> chunk should not be written unless the scene description and rendering parameters have been adjusted for a particular monitor. In that case, the data for that monitor should be used to construct a <a class="chunk" href="#11cHRM">cHRM</a> chunk.</p> <p>A few image formats store calibration information, which can be used to fill in the <a class="chunk" href="#11cHRM">cHRM</a> chunk. For example, TIFF 6.0 files [<cite><a class="bibref" data-link-type="biblio" href="#bib-tiff-6.0" title="TIFF Revision 6.0">TIFF-6.0</a></cite>] can optionally store calibration information, which if present should be used to construct the <a class="chunk" href="#11cHRM">cHRM</a> chunk.</p> <p>Video created with recent video equipment probably uses the CCIR 709 primaries and D65 <a href="#dfn-white-point" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-white-point-5">white point</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.709" title="ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange">ITU-R-BT.709</a></cite>], which are given in <a href="#12-table121" class="table-ref" title="CCIR 709 primaries and D65 whitepoint">Table <bdi class="">29</bdi></a>.</p> <table id="12-table121" class="numbered simple"> <caption><a class="self-link" href="#12-table121">Table <bdi class="tableno">29</bdi></a> <span class="table-title"> CCIR 709 primaries and D65 whitepoint </span></caption> <tbody><tr> <th> </th> <th>R</th> <th>G</th> <th>B</th> <th>White</th> </tr> <tr> <td>x</td> <td>0.640</td> <td>0.300</td> <td>0.150</td> <td>0.3127</td> </tr> <tr> <td>y</td> <td>0.330</td> <td>0.600</td> <td>0.060</td> <td>0.3290</td> </tr> </tbody></table> <p>An older but still very popular video standard is SMPTE-C [<cite><a class="bibref" data-link-type="biblio" href="#bib-smpte-170m" title="Television — Composite Analog Video Signal — NTSC for Studio Applications">SMPTE-170M</a></cite>] given in <a href="#12-table122" class="table-ref" title="SMPTE-C video standard">Table <bdi class="">30</bdi></a>.</p> <table id="12-table122" class="numbered simple"> <caption><a class="self-link" href="#12-table122">Table <bdi class="tableno">30</bdi></a> <span class="table-title"> SMPTE-C video standard </span></caption> <tbody><tr> <th> </th> <th>R</th> <th>G</th> <th>B</th> <th>White</th> </tr> <tr> <td>x</td> <td>0.630</td> <td>0.310</td> <td>0.155</td> <td>0.3127</td> </tr> <tr> <td>y</td> <td>0.340</td> <td>0.595</td> <td>0.070</td> <td>0.3290</td> </tr> </tbody></table> <p>It is <strong>not</strong> recommended that datastream format converters attempt to convert supplied images to a different RGB color space. The data should be stored in the PNG datastream without conversion, and the source primary chromaticities should be recorded if they are known. Color space transformation at datastream conversion time is a bad idea because of gamut mismatches and rounding errors. As with <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-12">gamma</a> conversions, it is better to store the data losslessly and incur at most one conversion when the image is finally displayed.</p> <p>See <a href="#13Decoder-colour-handling" class="sec-ref"><bdi class="secno">13.14 </bdi>Decoder color handling</a>.</p> </section> <section id="12Alpha-channel-creation"><div class="header-wrapper"><h3 id="x12-3-alpha-channel-creation"><bdi class="secno">12.3 </bdi>Alpha channel creation</h3><a class="self-link" href="#12Alpha-channel-creation" aria-label="Permalink for Section 12.3"></a></div> <p>The alpha channel can be regarded either as a mask that temporarily hides transparent parts of the image, or as a means for constructing a non-rectangular image. In the first case, the color values of fully transparent pixels should be preserved for future use. In the second case, the transparent pixels carry no useful data and are simply there to fill out the rectangular image area required by PNG. In this case, fully transparent pixels should all be assigned the same color value for best compression.</p> <p>Image authors should keep in mind the possibility that a decoder will not support transparency control in full (see <a href="#13Alpha-channel-processing" class="sec-ref"><bdi class="secno">13.16 </bdi>Alpha channel processing</a>). Hence, the colors assigned to transparent pixels should be reasonable background colors whenever feasible.</p> <p>For applications that do not require a full alpha channel, or cannot afford the price in compression efficiency, the <a class="chunk" href="#11tRNS">tRNS</a> transparency chunk is also available.</p> <p>If the image has a known background color, this color should be written in the <a class="chunk" href="#11bKGD">bKGD</a> chunk. Even decoders that ignore transparency may use the <a class="chunk" href="#11bKGD">bKGD</a> color to fill unused screen area.</p> <p>If the original image has premultiplied (also called "associated") alpha data, it can be converted to PNG's non-premultiplied format by dividing each sample value by the corresponding alpha value, then multiplying by the maximum value for the image bit depth, and rounding to the nearest integer. In valid premultiplied data, the sample values never exceed their corresponding alpha values, so the result of the division should always be in the range 0 to 1. If the alpha value is zero, output black (zeroes).</p> </section> <section id="12Sample-depth-scaling"><div class="header-wrapper"><h3 id="x12-4-sample-depth-scaling"><bdi class="secno">12.4 </bdi>Sample depth scaling</h3><a class="self-link" href="#12Sample-depth-scaling" aria-label="Permalink for Section 12.4"></a></div> <p>When encoding input samples that have a sample depth that cannot be directly represented in PNG, the encoder shall scale the samples up to a sample depth that is allowed by PNG. The most accurate scaling method is the linear equation:</p> <pre aria-busy="false"><code class="hljs">output = floor((input * MAXOUTSAMPLE / MAXINSAMPLE) + 0.5)</code></pre> <p>where the input samples range from 0 to <var>MAXINSAMPLE</var> and the outputs range from 0 to <var>MAXOUTSAMPLE</var> (which is 2<sup>sampledepth</sup>-1).</p> <p>A close approximation to the linear scaling method is achieved by "left bit replication", which is shifting the valid bits to begin in the most significant bit and repeating the most significant bits into the open bits. This method is often faster to compute than linear scaling.</p> <p class="example">Assume that 5-bit samples are being scaled up to 8 bits. If the source sample value is 27 (in the range from 0-31), then the original bits are:</p> <pre aria-busy="false"><code class="hljs">4 3 2 1 0 --------- 1 1 0 1 1</code></pre> <p>Left bit replication gives a value of 222:</p> <pre aria-busy="false"><code class="hljs">7 6 5 4 3 2 1 0 ---------------- 1 1 0 1 1 1 1 0 |=======| |===| | Leftmost Bits Repeated to Fill Open Bits | Original Bits</code></pre> <p>which matches the value computed by the linear equation. Left bit replication usually gives the same value as linear scaling, and is never off by more than one.</p> <p>A distinctly less accurate approximation is obtained by simply left-shifting the input value and filling the low order bits with zeroes. This scheme cannot reproduce white exactly, since it does not generate an all-ones maximum value; the net effect is to darken the image slightly. This method is not recommended in general, but it does have the effect of improving compression, particularly when dealing with greater-than-8-bit sample depths. Since the relative error introduced by zero-fill scaling is small at high sample depths, some encoders may choose to use it. Zero-fill shall <strong>not</strong> be used for alpha channel data, however, since many decoders will treat alpha values of all zeroes and all ones as special cases. It is important to represent both those values exactly in the scaled data.</p> <p>When the encoder writes an <a class="chunk" href="#11sBIT">sBIT</a> chunk, it is required to do the scaling in such a way that the high-order bits of the stored samples match the original data. That is, if the <a class="chunk" href="#11sBIT">sBIT</a> chunk specifies a sample depth of S, the high-order S bits of the stored data shall agree with the original S-bit data values. This allows decoders to recover the original data by shifting right. The added low-order bits are not constrained. All the above scaling methods meet this restriction.</p> <p>When scaling up source <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-17">image data</a>, it is recommended that the low-order bits be filled consistently for all samples; that is, the same source value should generate the same sample value at any pixel position. This improves compression by reducing the number of distinct sample values. This is not a mandatory requirement, and some encoders may choose not to follow it. For example, an encoder might instead dither the low-order bits, improving displayed image quality at the price of increasing file size.</p> <p>In some applications the original source data may have a range that is not a power of 2. The linear scaling equation still works for this case, although the shifting methods do not. It is recommended that an <a class="chunk" href="#11sBIT">sBIT</a> chunk not be written for such images, since <a class="chunk" href="#11sBIT">sBIT</a> suggests that the original data range was exactly 0..2<sup>S</sup>-1.</p> </section> <section id="12Suggested-palettes"><div class="header-wrapper"><h3 id="x12-5-suggested-palettes"><bdi class="secno">12.5 </bdi>Suggested palettes</h3><a class="self-link" href="#12Suggested-palettes" aria-label="Permalink for Section 12.5"></a></div> <p>Suggested palettes may appear as <a class="chunk" href="#11sPLT">sPLT</a> chunks in any PNG datastream, or as a <a class="chunk" href="#11PLTE">PLTE</a> chunk in <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-15">truecolor</a> PNG datastreams. In either case, the suggested palette is not an essential part of the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-18">image data</a>, but it may be used to present the image on indexed-color display hardware. Suggested palettes are of no interest to viewers running on <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-16">truecolor</a> hardware.</p> <p>When an <a class="chunk" href="#11sPLT">sPLT</a> chunk is used to provide a suggested palette, it is recommended that the encoder use the frequency fields to indicate the relative importance of the palette entries, rather than leave them all zero (meaning undefined). The frequency values are most easily computed as "nearest neighbor" counts, that is, the approximate usage of each RGBA palette entry if no dithering is applied. (These counts will often be available "for free" as a consequence of developing the suggested palette.) Because the suggested palette includes transparency information, it should be computed for the un-<a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-7">composited</a> image.</p> <p>Even for indexed-color images, <a class="chunk" href="#11sPLT">sPLT</a> can be used to define alternative reduced palettes for viewers that are unable to display all the colors present in the <a class="chunk" href="#11PLTE">PLTE</a> chunk. If the <a class="chunk" href="#11PLTE">PLTE</a> chunk appears without the <a class="chunk" href="#11bKGD">bKGD</a> chunk in an image of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-33">color type</a> 6, the circumstances under which the palette was computed are unspecified.</p> <p>An older method for including a suggested palette in a <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-17">truecolor</a> PNG datastream uses the <a class="chunk" href="#11PLTE">PLTE</a> chunk. If this method is used, the histogram (frequencies) should appear in a separate <a class="chunk" href="#11hIST">hIST</a> chunk. The <a class="chunk" href="#11PLTE">PLTE</a> chunk does not include transparency information. Hence for images of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-34">color type</a> 6 (<a href="#dfn-truecolor-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-truecolor-with-alpha-5">truecolor with alpha</a>), it is recommended that a <a class="chunk" href="#11bKGD">bKGD</a> chunk appear and that the palette and histogram be computed with reference to the image as it would appear after compositing against the specified background color. This definition is necessary to ensure that useful palette entries are generated for pixels having fractional alpha values. The resulting palette will probably be useful only to viewers that present the image against the same background color. It is recommended that <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-4">PNG editors</a> delete or recompute the palette if they alter or remove the <a class="chunk" href="#11bKGD">bKGD</a> chunk in an image of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-35">color type</a> 6.</p> <p>For images of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-36">color type</a> 2 (<a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-18">truecolor</a>), it is recommended that the <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11hIST">hIST</a> chunks be computed with reference to the RGB data only, ignoring any transparent-color specification. If the datastream uses transparency (has a <a class="chunk" href="#11tRNS">tRNS</a> chunk), viewers can easily adapt the resulting palette for use with their intended background color (see <a href="#13Histogram-and-suggested-palette-usage" class="sec-ref"><bdi class="secno">13.17 </bdi>Histogram and suggested palette usage</a>).</p> <p>For providing suggested palettes, the <a class="chunk" href="#11sPLT">sPLT</a> chunk is more flexible than the <a class="chunk" href="#11PLTE">PLTE</a> chunk in the following ways:</p> <ol> <li>With <a class="chunk" href="#11sPLT">sPLT</a> multiple suggested palettes may be provided. A PNG decoder may choose an appropriate palette based on name or number of entries. </li> <li>In a PNG datastream of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-37">color type</a> 6 (<a href="#dfn-truecolor-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-truecolor-with-alpha-6">truecolor with alpha</a> channel), the <a class="chunk" href="#11PLTE">PLTE</a> chunk represents a palette already <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-8">composited</a> against the <a class="chunk" href="#11bKGD">bKGD</a> color, so it is useful only for display against that background color. The <a class="chunk" href="#11sPLT">sPLT</a> chunk provides an un-<a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-9">composited</a> palette, which is useful for display against backgrounds chosen by the PNG decoder. </li> <li>Since the <a class="chunk" href="#11sPLT">sPLT</a> chunk is an ancillary chunk, a <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-5">PNG editor</a> may add or modify suggested palettes without being forced to discard unknown unsafe-to-copy chunks. </li> <li>Whereas the <a class="chunk" href="#11sPLT">sPLT</a> chunk is allowed in PNG datastreams for <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-38">color types</a> 0, 3, and 4 (<a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-13">greyscale</a> and <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-16">indexed-color</a>), the <a class="chunk" href="#11PLTE">PLTE</a> chunk cannot be used to provide reduced palettes in these cases. </li> <li>More than 256 entries may appear in the <a class="chunk" href="#11sPLT">sPLT</a> chunk. </li> </ol> <p>A PNG encoder that uses the <a class="chunk" href="#11sPLT">sPLT</a> chunk may choose to write a suggested palette represented by <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11hIST">hIST</a> chunks as well, for compatibility with decoders that do not recognize the <a class="chunk" href="#11sPLT">sPLT</a> chunk.</p> </section> <section id="12Interlacing"><div class="header-wrapper"><h3 id="x12-6-interlacing"><bdi class="secno">12.6 </bdi>Interlacing</h3><a class="self-link" href="#12Interlacing" aria-label="Permalink for Section 12.6"></a></div> <p>This specification defines two interlace methods, one of which is no interlacing. Interlacing provides a convenient basis from which decoders can progressively display an image, as described in <a href="#13Progressive-display" class="sec-ref"><bdi class="secno">13.10 </bdi>Interlacing and progressive display</a>.</p> </section> <section id="12Filter-selection"><div class="header-wrapper"><h3 id="x12-7-filter-selection"><bdi class="secno">12.7 </bdi>Filter selection</h3><a class="self-link" href="#12Filter-selection" aria-label="Permalink for Section 12.7"></a></div> <p>For images of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-39">color type</a> 3 (indexed-color), filter type 0 (None) is usually the most effective. Color images with 256 or fewer colors should almost always be stored in <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-17">indexed-color</a> format; <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-19">truecolor</a> format is likely to be much larger.</p> <p>Filter type 0 is also recommended for images of bit depths less than 8. For low-bit-depth greyscale images, in rare cases, better compression may be obtained by first expanding the image to 8-bit representation and then applying filtering.</p> <p>For <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-20">truecolor</a> and <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-14">greyscale</a> images, any of the five filters may prove the most effective. If an encoder uses a fixed filter, the Paeth filter type is most likely to be the best.</p> <p>For best compression of <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-21">truecolor</a> and <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-15">greyscale</a> images, and if compression efficiency is valued over speed of compression, the recommended approach is adaptive filtering in which a filter type is chosen for each scanline. Each unique image will have a different set of filters which perform best for it. An encoder could try every combination of filters to find what compresses best for a given image. However, when an exhaustive search is unacceptable, here are some general heuristics which may perform well enough: compute the output scanline using all five filters, and select the filter that gives the smallest sum of absolute values of outputs. (Consider the output bytes as signed differences for this test.) This method usually outperforms any single fixed filter type choice.</p> <p>Filtering according to these recommendations is effective in conjunction with either of the two interlace methods defined in this specification.</p> </section> <section id="12Compression"><div class="header-wrapper"><h3 id="x12-8-compression"><bdi class="secno">12.8 </bdi>Compression</h3><a class="self-link" href="#12Compression" aria-label="Permalink for Section 12.8"></a></div> <p>The encoder may divide the compressed datastream into <a class="chunk" href="#11IDAT">IDAT</a> chunks however it wishes. (Multiple <a class="chunk" href="#11IDAT">IDAT</a> chunks are allowed so that encoders may work in a fixed amount of memory; typically the chunk size will correspond to the encoder's buffer size.) A PNG datastream in which each <a class="chunk" href="#11IDAT">IDAT</a> chunk contains only one data byte is valid, though remarkably wasteful of space. (<a href="#zero-length-data">Zero-length</a> <a class="chunk" href="#11IDAT">IDAT</a> chunks are also valid, though even more wasteful.)</p> </section> <section id="12Text-chunk-processing"><div class="header-wrapper"><h3 id="x12-9-text-chunk-processing"><bdi class="secno">12.9 </bdi>Text chunk processing</h3><a class="self-link" href="#12Text-chunk-processing" aria-label="Permalink for Section 12.9"></a></div> <p>A nonempty keyword shall be provided for each text chunk. The generic keyword "Comment" can be used if no better description of the text is available. If a user-supplied keyword is used, encoders should check that it meets the restrictions on keywords.</p> <p>The <a class="chunk" href="#11iTXt">iTXt</a> chunk uses the UTF-8 encoding of Unicode and thus can store text in any language. The <a class="chunk" href="#11tEXt">tEXt</a> and <a class="chunk" href="#11zTXt">zTXt</a> chunks use the Latin-1 (ISO 8859-1) character encoding, which limits the range of characters that can be used in these chunks. Encoders should prefer <a class="chunk" href="#11iTXt">iTXt</a> to <a class="chunk" href="#11tEXt">tEXt</a> and <a class="chunk" href="#11zTXt">zTXt</a> chunks, in order to allow a wide range of characters without data loss. Encoders must convert characters that use local <a data-link-type="dfn" href="https://www.w3.org/TR/i18n-glossary/#dfn-legacy-character-encodings">legacy character encodings</a> to the appropriate encoding when storing text. </p> <p>When creating <a href="#11iTXt" class="chunk">iTXt</a> chunks, encoders should follow <a href="https://encoding.spec.whatwg.org/#utf-8-encode">UTF-8 encode</a> in <cite><a data-matched-text="[[[ENCODING]]]" href="https://encoding.spec.whatwg.org/">Encoding Standard</a></cite>. </p> <p>Encoders should discourage the creation of single lines of text longer than 79 Unicode <a data-link-type="dfn" href="https://www.w3.org/TR/i18n-glossary/#dfn-code-point">code points</a>, in order to facilitate easy reading. It is recommended that text items less than 1024 bytes in size should be output using uncompressed text chunks. It is recommended that the basic title and author keywords be output using uncompressed text chunks. Placing large text chunks after the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-19">image data</a> (after the <a class="chunk" href="#11IDAT">IDAT</a> chunks) can speed up image display in some situations, as the decoder will decode the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-20">image data</a> first. It is recommended that small text chunks, such as the image title, appear before the <a class="chunk" href="#11IDAT">IDAT</a> chunks.</p> </section> <section id="12Chunk-processing"><div class="header-wrapper"><h3 id="x12-10-chunking"><bdi class="secno">12.10 </bdi>Chunking</h3><a class="self-link" href="#12Chunk-processing" aria-label="Permalink for Section 12.10"></a></div> <section id="12Use-of-private-chunks"><div class="header-wrapper"><h4 id="x12-10-1-use-of-private-chunks"><bdi class="secno">12.10.1 </bdi>Use of private chunks</h4><a class="self-link" href="#12Use-of-private-chunks" aria-label="Permalink for Section 12.10.1"></a></div> <p>Encoders <em class="rfc2119">MAY</em> use private chunks to carry information that need not be understood by other applications.</p> </section> <section id="12Private-type-and-method-codes"><div class="header-wrapper"><h4 id="x12-10-2-use-of-non-reserved-field-values"><bdi class="secno">12.10.2 </bdi>Use of non-reserved field values</h4><a class="self-link" href="#12Private-type-and-method-codes" aria-label="Permalink for Section 12.10.2"></a></div> <p>Encoders <em class="rfc2119">MAY</em> use non-reserved field values for experimental or private use.</p> </section> <section id="12Ancillary"><div class="header-wrapper"><h4 id="x12-10-3-ancillary-chunks"><bdi class="secno">12.10.3 </bdi>Ancillary chunks</h4><a class="self-link" href="#12Ancillary" aria-label="Permalink for Section 12.10.3"></a></div> <p>All ancillary chunks are optional, encoders need not write them. However, encoders are encouraged to write the standard ancillary chunks when the information is available.</p> </section> </section> </section> <section id="13Decoders"><div class="header-wrapper"><h2 id="x13-png-decoders-and-viewers"><bdi class="secno">13. </bdi>PNG decoders and viewers</h2><a class="self-link" href="#13Decoders" aria-label="Permalink for Section 13."></a></div> <section class="introductory" id="13Introduction"><div class="header-wrapper"><h2 id="introduction-9">Introduction</h2><a class="self-link" href="#13Introduction" aria-label="Permalink for this Section"></a></div> <p>This clause gives some requirements and recommendations for PNG decoder behavior and viewer behavior. A viewer presents the decoded PNG image to the user. Since viewer and decoder behavior are closely connected, decoders and viewers are treated together here. The only absolute requirement on a PNG decoder is that it successfully reads any datastream conforming to the format specified in the preceding chapters. However, best results will usually be achieved by following these additional recommendations.</p> <p>PNG decoders shall support all valid combinations of bit depth, <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-40">color type</a>, compression method, <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-13">filter method</a>, and interlace method that are explicitly defined in this International Standard.</p> </section> <section id="error-handling"><div class="header-wrapper"><h3 id="13Decoders.Errors"><bdi class="secno">13.1 </bdi>Error handling</h3><a class="self-link" href="#13Decoders.Errors" aria-label="Permalink for Section 13.1"></a></div> <p>Errors in a PNG datastream will fall into two general classes, transmission errors and syntax errors (see <a href="#4Concepts.Errors" class="sec-ref"><bdi class="secno">4.10 </bdi>Error handling</a>).</p> <p>Examples of transmission errors are transmission in "text" or "ascii" mode, in which byte codes 13 and/or 10 may be added, removed, or converted throughout the datastream; unexpected termination, in which the datastream is truncated; or a physical error on a storage device, in which one or more blocks (typically 512 bytes each) will have garbled or random values. Some examples of syntax errors are an invalid value for a row filter, an invalid compression method, an invalid chunk length, the absence of a <a class="chunk" href="#11PLTE">PLTE</a> chunk before the first <a class="chunk" href="#11IDAT">IDAT</a> chunk in an indexed image, or the presence of multiple <a class="chunk" href="#11gAMA">gAMA</a> chunks. A PNG decoder should handle errors as follows:</p> <ol> <li>Detect errors as early as possible using the PNG signature bytes and CRCs on each chunk. Decoders should verify that all eight bytes of the PNG signature are correct. A decoder can have additional confidence in the datastream's integrity if the next eight bytes begin an <a class="chunk" href="#11IHDR">IHDR</a> chunk with the correct chunk length. A <abbr title="Cyclic Redundancy Code">CRC</abbr> should be checked before processing the chunk data. Sometimes this is impractical, for example when a streaming PNG decoder is processing a large <a class="chunk" href="#11IDAT">IDAT</a> chunk. In this case the <abbr title="Cyclic Redundancy Code">CRC</abbr> should be checked when the end of the chunk is reached. </li> <li>Recover from an error, if possible; otherwise fail gracefully. Errors that have little or no effect on the processing of the image may be ignored, while those that affect critical data shall be dealt with in a manner appropriate to the application.</li> <li>Provide helpful messages describing errors, including recoverable errors.</li> </ol> <p>Three classes of PNG chunks are relevant to this philosophy. For the purposes of this classification, an "unknown chunk" is either one whose type was genuinely unknown to the decoder's author, or one that the author chose to treat as unknown, because default handling of that chunk type would be sufficient for the program's purposes. Other chunks are called "known chunks". Given this definition, the three classes are as follows:</p> <ol> <li>known chunks, which necessarily includes all of the critical chunks defined in this specification (<a class="chunk" href="#11IHDR">IHDR</a>, <a class="chunk" href="#11PLTE">PLTE</a>, <a class="chunk" href="#11IDAT">IDAT</a>, <a class="chunk" href="#11IEND">IEND</a>) </li> <li>unknown critical chunks (bit 5 of the first byte of the chunk type is 0)</li> <li>unknown ancillary chunks (bit 5 of the first byte of the chunk type is 1)</li> </ol> <p>See <a href="#5Chunk-naming-conventions" class="sec-ref"><bdi class="secno">5.4 </bdi>Chunk naming conventions</a> for a description of chunk naming conventions.</p> <p>PNG chunk types are marked "critical" or "ancillary" according to whether the chunks are critical for the purpose of extracting a viewable image (as with <a class="chunk" href="#11IHDR">IHDR</a>, <a class="chunk" href="#11PLTE">PLTE</a>, and <a class="chunk" href="#11IDAT">IDAT</a>) or critical to understanding the datastream structure (as with <a class="chunk" href="#11IEND">IEND</a>). This is a specific kind of criticality and one that is not necessarily relevant to every conceivable decoder. For example, a program whose sole purpose is to extract text annotations (for example, copyright information) does not require a viewable image but should <a href="https://encoding.spec.whatwg.org/#utf-8-decode">decode UTF-8 correctly</a>. Another decoder might consider the <a class="chunk" href="#11tRNS">tRNS</a> and <a class="chunk" href="#11gAMA">gAMA</a> chunks essential to its proper execution.</p> <p>Syntax errors always involve known chunks because syntax errors in unknown chunks cannot be detected. The PNG decoder has to determine whether a syntax error is fatal (unrecoverable) or not, depending on its requirements and the situation. For example, most decoders can ignore an invalid <a class="chunk" href="#11IEND">IEND</a> chunk; a text-extraction program can ignore the absence of <a class="chunk" href="#11IDAT">IDAT</a>; an image viewer cannot recover from an empty <a class="chunk" href="#11PLTE">PLTE</a> chunk in an indexed image but it can ignore an invalid <a class="chunk" href="#11PLTE">PLTE</a> chunk in a <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-22">truecolor</a> image; and a program that extracts the alpha channel can ignore an invalid <a class="chunk" href="#11gAMA">gAMA</a> chunk, but may consider the presence of two <a class="chunk" href="#11tRNS">tRNS</a> chunks to be a fatal error. Anomalous situations other than syntax errors shall be treated as follows:</p> <ol> <li>Encountering an unknown ancillary chunk is never an error. The chunk can simply be ignored.</li> <li>Encountering an unknown critical chunk is a fatal condition for any decoder trying to extract the image from the datastream. A decoder that ignored a critical chunk could not know whether the image it extracted was the one intended by the encoder.</li> <li>A PNG signature mismatch, a <abbr title="Cyclic Redundancy Code">CRC</abbr> mismatch, or an unexpected end-of-stream indicates a corrupted datastream, and may be regarded as a fatal error. A decoder could try to salvage something from the datastream, but the extent of the damage will not be known. </li> </ol> <p>When a fatal condition occurs, the decoder should fail immediately, signal an error to the user if appropriate, and optionally continue displaying any <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-21">image data</a> already visible to the user (i.e. "fail gracefully"). The application as a whole need not terminate.</p> <p>When a non-fatal error occurs, the decoder should signal a warning to the user if appropriate, recover from the error, and continue processing normally.</p> <p>When decoding an indexed-color PNG, if out-of-range indexes are encountered, decoders have historically varied in their handling of this error. <span id="oor-index-black">Displaying the pixel as opaque black</span> is one common error recovery tactic, and is now required by this specification. Older implementations will vary, and so the behavior must not be relied on by encoders.</p> <p>Decoders that do not compute CRCs should interpret apparent syntax errors as indications of corruption (see also <a href="#13Error-checking" class="sec-ref"><bdi class="secno">13.2 </bdi>Error checking</a>).</p> <p>Errors in compressed chunks ( <a class="chunk" href="#11IDAT">IDAT</a>, <a class="chunk" href="#11zTXt">zTXt</a>, <a class="chunk" href="#11iTXt">iTXt</a>, <a class="chunk" href="#11iCCP">iCCP</a>) could lead to buffer overruns. Implementors of <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-16">deflate</a> decompressors should guard against this possibility.</p> <p><abbr title="Animated PNG">APNG</abbr> is designed to allow incremental display of frames before the entire <a href="#5DataRep">datastream</a> has been read. This implies that some errors may not be detected until partway through the animation. It is strongly recommended that when any error is encountered decoders should discard all subsequent frames, stop the animation, and revert to displaying the static image. A decoder which detects an error before the animation has started should display the static image. An error message may be displayed to the user if appropriate.</p> <p>Decoders shall treat out-of-order <abbr title="Animated PNG">APNG</abbr> chunks as an error. <abbr title="Animated PNG">APNG</abbr>-aware <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-6">PNG editors</a> should restore them to correct order, using the sequence numbers.</p> </section> <section id="13Error-checking"><div class="header-wrapper"><h3 id="x13-2-error-checking"><bdi class="secno">13.2 </bdi>Error checking</h3><a class="self-link" href="#13Error-checking" aria-label="Permalink for Section 13.2"></a></div> <p>The PNG error handling philosophy is described in <a href="#13Decoders.Errors" class="sec-ref"><bdi class="secno">13.1 </bdi>Error handling</a>.</p> <p>An unknown chunk type is <strong>not</strong> to be treated as an error unless it is a critical chunk.</p> <p>The chunk type can be checked for plausibility by seeing whether all four bytes are in the range codes 41-5A and 61-7A (hexadecimal); note that this need be done only for unrecognized chunk types. If the total datastream size is known (from file system information, HTTP protocol, etc), the chunk length can be checked for plausibility as well. If CRCs are not checked, dropped/added data bytes or an erroneous chunk length can cause the decoder to get out of step and misinterpret subsequent data as a chunk header.</p> <p>For known-length chunks, such as <a class="chunk" href="#11IHDR">IHDR</a>, decoders should treat an unexpected chunk length as an error. Future extensions to this specification will not add new fields to existing chunks; instead, new chunk types will be added to carry new information.</p> <p>Unexpected values in fields of known chunks (for example, an unexpected compression method in the <a class="chunk" href="#11IHDR">IHDR</a> chunk) shall be checked for and treated as errors. However, it is recommended that unexpected field values be treated as fatal errors only in <strong>critical</strong> chunks. An unexpected value in an ancillary chunk can be handled by ignoring the whole chunk as though it were an unknown chunk type. (This recommendation assumes that the chunk's <abbr title="Cyclic Redundancy Code">CRC</abbr> has been verified. In decoders that do not check CRCs, it is safer to treat any unexpected value as indicating a corrupted datastream.)</p> <p>Standard PNG images shall be compressed with compression method 0. The compression method field of the <a class="chunk" href="#11IHDR">IHDR</a> chunk is provided for possible future standardization or proprietary variants. Decoders shall check this byte and report an error if it holds an unrecognized code. See <a href="#10Compression" class="sec-ref"><bdi class="secno">10. </bdi>Compression</a> for details.</p> </section> <section id="13Security-considerations"><div class="header-wrapper"><h3 id="x13-3-security-considerations"><bdi class="secno">13.3 </bdi>Security considerations</h3><a class="self-link" href="#13Security-considerations" aria-label="Permalink for Section 13.3"></a></div> <p>A PNG datastream is composed of a collection of explicitly typed chunks. Chunks whose contents are defined by the specification could actually contain anything, including malicious code. Similarly there could be data after the <a class="chunk" href="#11IEND">IEND</a> chunk which could contain anything, including malicious code. There is no known risk that such malicious code could be executed on the recipient's computer <em>as a result of decoding the PNG image</em>. However, a malicious application might hide such code inside an innocent-looking image file and then execute it.</p> <p>The possible security risks associated with future chunk types cannot be specified at this time. Security issues will be considered when defining future public chunks. There is no additional security risk associated with unknown or unimplemented chunk types, because such chunks will be ignored, or at most be copied into another PNG datastream.</p> <p>The <a class="chunk" href="#11iTXt">iTXt</a>, <a class="chunk" href="#11tEXt">tEXt</a>, and <a class="chunk" href="#11zTXt">zTXt</a> chunks contain keywords and data that are meant to be displayed as plain text. The <a class="chunk" href="#11iCCP">iCCP</a> and <a class="chunk" href="#11sPLT">sPLT</a> chunks contain keywords that are meant to be displayed as plain text. It is possible that if the decoder displays such text without filtering out control characters, especially the ESC (escape) character, certain systems or terminals could behave in undesirable and insecure ways. It is recommended that decoders filter out control characters to avoid this risk; see <a href="#13Text-chunk-processing" class="sec-ref"><bdi class="secno">13.7 </bdi>Text chunk processing</a>.</p> <p>For the <a class="chunk" href="#eXIf">eXIf</a> chunk, the Exif Specification [<cite><a class="bibref" data-link-type="biblio" href="#bib-cipa-dc-008" title="Exchangeable image file format for digital still cameras: Exif Version 2.32">CIPA-DC-008</a></cite>] does not contain an express requirement that tag "value offset" pointers must actually point to a valid address within the file. This requirement is merely implied. (See Paragraph 4.6.2, which describes the Exif IFD structure.) Regardless, decoders should be prepared to encounter invalid pointers and to handle them appropriately.</p> <p>Every chunk begins with a length field, which makes it easier to write decoders that are invulnerable to fraudulent chunks that attempt to overflow buffers. The <abbr title="Cyclic Redundancy Code">CRC</abbr> at the end of every chunk provides a robust defence against accidentally corrupted data. The PNG signature bytes provide early detection of common file transmission errors.</p> <p>A decoder that fails to check CRCs could be subject to data corruption. The only likely consequence of such corruption is incorrectly displayed pixels within the image. Worse things might happen if the <abbr title="Cyclic Redundancy Code">CRC</abbr> of the <a class="chunk" href="#11IHDR">IHDR</a> chunk is not checked and the width or height fields are corrupted. See <a href="#13Error-checking" class="sec-ref"><bdi class="secno">13.2 </bdi>Error checking</a>.</p> <p>A poorly written decoder might be subject to buffer overflow, because chunks can be extremely large, up to 2<sup>31</sup>-1 bytes long. But properly written decoders will handle large chunks without difficulty.</p> </section> <section id="Privacy-considerations"><div class="header-wrapper"><h3 id="x13-4-privacy-considerations"><bdi class="secno">13.4 </bdi>Privacy considerations</h3><a class="self-link" href="#Privacy-considerations" aria-label="Permalink for Section 13.4"></a></div> <p>Some image editing tools have historically performed redaction by merely setting the alpha channel of the redacted area to zero, without also removing the actual image data. Users who rely solely on the visual appearance of such images run a privacy risk because the actual image data can be easily recovered.</p> <p>Similarly, some image editing tools have historically performed clipping by rewriting the width and height in <span class="chunk">IHDR</span> without re-encoding the image data, which thus extends beyond the new width and height and may be recovered.</p> <p>Images with <span class="chunk">eXIf</span> chunks may contain automatically-included data, such as photographic GPS coordinates, which could be a privacy risk if the user is unaware that the PNG image contains this data. (Other image formats that contain EXIF, such as JPEG/JFIF, have the same privacy risk).</p> </section> <section id="13Chunking"><div class="header-wrapper"><h3 id="x13-5-chunking"><bdi class="secno">13.5 </bdi>Chunking</h3><a class="self-link" href="#13Chunking" aria-label="Permalink for Section 13.5"></a></div> <p>Decoders shall recognize chunk types by a simple four-byte literal comparison; it is incorrect to perform case conversion on chunk types. A decoder encountering an unknown chunk in which the ancillary bit is 1 may safely ignore the chunk and proceed to display the image. A decoder trying to extract the image, upon encountering an unknown chunk in which the ancillary bit is 0, indicating a critical chunk, shall indicate to the user that the image contains information it cannot safely interpret.</p> <p>Decoders should test the properties of an unknown chunk type by numerically testing the specified bits. Testing whether a character is uppercase or lowercase is inefficient, and even incorrect if a locale-specific case definition is used.</p> <p>Decoders should not flag an error if the reserved bit is set to 1, however, as some future version of the PNG specification could define a meaning for this bit. It is sufficient to treat a chunk with this bit set in the same way as any other unknown chunk type.</p> <p>Decoders do not need to test the chunk type private bit, since it has no functional significance and is used to avoid conflicts between chunks defined by <abbr title="World Wide Web Consortium">W3C</abbr> and those defined privately.</p> <p>All ancillary chunks are optional; decoders may ignore them. However, decoders are encouraged to interpret these chunks when appropriate and feasible.</p> </section> <section id="13Pixel-dimensions"><div class="header-wrapper"><h3 id="x13-6-pixel-dimensions"><bdi class="secno">13.6 </bdi>Pixel dimensions</h3><a class="self-link" href="#13Pixel-dimensions" aria-label="Permalink for Section 13.6"></a></div> <p>Non-square pixels can be represented (see <a href="#11pHYs" class="sec-ref"><bdi class="secno">11.3.4.3 </bdi><span class="chunk">pHYs</span> Physical pixel dimensions</a>), but viewers are not required to account for them; a viewer can present any PNG datastream as though its pixels are square.</p> <p>Where the pixel aspect ratio of the display differs from the aspect ratio of the physical pixel dimensions defined in the PNG datastream, viewers are strongly encouraged to rescale images for proper display.</p> <p>When the <a class="chunk" href="#11pHYs">pHYs</a> chunk has a unit specifier of 0 (unit is unknown), the behavior of a decoder may depend on the ratio of the two pixels-per-unit values, but should not depend on their magnitudes. For example, a <a class="chunk" href="#11pHYs">pHYs</a> chunk containing <code>(ppuX, ppuY, unit) = (2, 1, 0)</code> is equivalent to one containing <code>(1000, 500, 0)</code>; both are equally valid indications that the image pixels are twice as tall as they are wide.</p> <p>One reasonable way for viewers to handle a difference between the pixel aspect ratios of the image and the display is to expand the image either horizontally or vertically, but not both. The scale factors could be obtained using the following floating-point calculations:</p> <pre><code aria-busy="false" class="hljs">image_ratio = pHYs_ppuY / pHYs_ppuX display_ratio = display_ppuY / display_ppuX scale_factor_X = max(1.0, image_ratio/display_ratio) scale_factor_Y = max(1.0, display_ratio/image_ratio)</code></pre> <p>Because other methods such as maintaining the image area are also reasonable, and because ignoring the <a class="chunk" href="#11pHYs">pHYs</a> chunk is permissible, authors should not assume that all viewing applications will use this scaling method.</p> <p>As well as making corrections for pixel aspect ratio, a viewer may have reasons to perform additional scaling both horizontally and vertically. For example, a viewer might want to shrink an image that is too large to fit on the display, or to expand images sent to a high-resolution printer so that they appear the same size as they did on the display.</p> </section> <section id="13Text-chunk-processing"><div class="header-wrapper"><h3 id="x13-7-text-chunk-processing"><bdi class="secno">13.7 </bdi>Text chunk processing</h3><a class="self-link" href="#13Text-chunk-processing" aria-label="Permalink for Section 13.7"></a></div> <p>If practical, PNG decoders should have a way to display to the user all the <a class="chunk" href="#11iTXt">iTXt</a>, <a class="chunk" href="#11tEXt">tEXt</a>, and <a class="chunk" href="#11zTXt">zTXt</a> chunks found in the datastream. Even if the decoder does not recognize a particular text keyword, the user might be able to understand it.</p> <p>When processing <a class="chunk" href="#11tEXt">tEXt</a> and <a class="chunk" href="#11zTXt">zTXt</a> chunks, decoders could encounter characters other than those permitted. Some can be safely displayed (e.g., TAB, FF, and CR, hexadecimal 09, 0C, and 0D, respectively), but others, especially the ESC character (hexadecimal 1B), could pose a security hazard (because unexpected actions may be taken by display hardware or software). Decoders should not attempt to directly display any non-Latin-1 characters (except for newline and perhaps TAB, FF, CR) encountered in a <a class="chunk" href="#11tEXt">tEXt</a> or <a class="chunk" href="#11zTXt">zTXt</a> chunk. Instead, they should be ignored or displayed in a visible notation such as "<code>\nnn</code>". See <a href="#13Security-considerations" class="sec-ref"><bdi class="secno">13.3 </bdi>Security considerations</a>.</p> <p>When processing <a href="#11iTXt" class="chunk">iTXt</a> chunks, decoders should follow <a href="https://encoding.spec.whatwg.org/#utf-8-decode">UTF-8 decode</a> in <cite><a data-matched-text="[[[ENCODING]]]" href="https://encoding.spec.whatwg.org/">Encoding Standard</a></cite>. </p> <p>Even though encoders are recommended to represent newlines as linefeed (hexadecimal 0A), it is recommended that decoders not rely on this; it is best to recognize all the common newline combinations (CR, LF, and CR-LF) and display each as a single newline. TAB can be expanded to the proper number of spaces needed to arrive at a column multiple of 8.</p> <p>Decoders running on systems with a non-Latin-1 <a data-link-type="dfn" href="https://www.w3.org/TR/i18n-glossary/#dfn-legacy-character-encodings">legacy character encoding</a> should remap character codes so that Latin-1 characters are displayed correctly. Unsupported characters should be replaced with a system-appropriate replacement character (such as U+FFFD REPLACEMENT CHARACTER, U+003F QUESTION MARK, or U+001A SUB) or mapped to a visible notation such as "<code>\nnn</code>". Characters should be only displayed if they are printable characters on the decoding system. Some byte values may be interpreted by the decoding system as control characters; for security, decoders running on such systems should not display these control characters.</p> <p>Decoders should be prepared to display text chunks that contain any number of printing characters between newline characters, even though it is recommended that encoders avoid creating lines in excess of 79 characters.</p> </section> <section id="13Decompression"><div class="header-wrapper"><h3 id="x13-8-decompression"><bdi class="secno">13.8 </bdi>Decompression</h3><a class="self-link" href="#13Decompression" aria-label="Permalink for Section 13.8"></a></div> <p>The compression technique used in this specification does not require the entire compressed datastream to be available before decompression can start. Display can therefore commence before the entire decompressed datastream is available. It is extremely unlikely that any general purpose compression methods in future versions of this specification will not have this property.</p> <p>It is important to emphasize that <a class="chunk" href="#11IDAT">IDAT</a> chunk boundaries have no semantic significance and can occur at any point in the compressed datastream. There is no required correlation between the structure of the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-22">image data</a> (for example, scanline boundaries) and <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-17">deflate</a> block boundaries or <a class="chunk" href="#11IDAT">IDAT</a> chunk boundaries. The complete <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-23">image data</a> is represented by a single <a href="#dfn-zlib" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-zlib-18">zlib</a> datastream that is stored in some number of <a class="chunk" href="#11IDAT">IDAT</a> chunks; a decoder that assumes any more than this is incorrect. Some encoder implementations may emit datastreams in which some of these structures are indeed related, but decoders cannot rely on this.</p> </section> <section id="13Filtering"><div class="header-wrapper"><h3 id="x13-9-filtering"><bdi class="secno">13.9 </bdi>Filtering</h3><a class="self-link" href="#13Filtering" aria-label="Permalink for Section 13.9"></a></div> <p>To reverse the effect of a filter, the decoder may need to use the decoded values of the prior pixel on the same line, the pixel immediately above the current pixel on the prior line, and the pixel just to the left of the pixel above. This implies that at least one scanline's worth of <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-24">image data</a> needs to be stored by the decoder at all times. Even though some filter types do not refer to the prior scanline, the decoder will always need to store each scanline as it is decoded, since the next scanline might use a filter type that refers to it. See <a href="#7Filtering" class="sec-ref"><bdi class="secno">7.3 </bdi>Filtering</a>.</p> </section> <section id="13Progressive-display"><div class="header-wrapper"><h3 id="x13-10-interlacing-and-progressive-display"><bdi class="secno">13.10 </bdi>Interlacing and progressive display</h3><a class="self-link" href="#13Progressive-display" aria-label="Permalink for Section 13.10"></a></div> <p>Decoders are required to be able to read interlaced images. If the reference image contains fewer than five columns or fewer than five rows, some passes will be empty. Encoders and decoders shall handle this case correctly. In particular, filter type bytes are associated only with nonempty scanlines; no filter type bytes are present in an empty reduced image.</p> <p>When receiving images over slow transmission links, viewers can improve perceived performance by displaying interlaced images progressively. This means that as each reduced image is received, an approximation to the complete image is displayed based on the data received so far. One simple yet pleasing effect can be obtained by expanding each received pixel to fill a rectangle covering the yet-to-be-transmitted pixel positions below and to the right of the received pixel. This process can be described by the following ISO C code [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso_9899" title="ISO/IEC 9899:2018 Information technology — Programming languages — C">ISO_9899</a></cite>]:</p> <pre aria-busy="false"><code class="hljs javascript"><span class="hljs-comment">/* variables declared and initialized elsewhere in the code: height, width functions or macros defined elsewhere in the code: visit(), min() */</span> int starting_row[<span class="hljs-number">7</span>] = { <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">4</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span> }; int starting_col[<span class="hljs-number">7</span>] = { <span class="hljs-number">0</span>, <span class="hljs-number">4</span>, <span class="hljs-number">0</span>, <span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span> }; int row_increment[<span class="hljs-number">7</span>] = { <span class="hljs-number">8</span>, <span class="hljs-number">8</span>, <span class="hljs-number">8</span>, <span class="hljs-number">4</span>, <span class="hljs-number">4</span>, <span class="hljs-number">2</span>, <span class="hljs-number">2</span> }; int col_increment[<span class="hljs-number">7</span>] = { <span class="hljs-number">8</span>, <span class="hljs-number">8</span>, <span class="hljs-number">4</span>, <span class="hljs-number">4</span>, <span class="hljs-number">2</span>, <span class="hljs-number">2</span>, <span class="hljs-number">1</span> }; int block_height[<span class="hljs-number">7</span>] = { <span class="hljs-number">8</span>, <span class="hljs-number">8</span>, <span class="hljs-number">4</span>, <span class="hljs-number">4</span>, <span class="hljs-number">2</span>, <span class="hljs-number">2</span>, <span class="hljs-number">1</span> }; int block_width[<span class="hljs-number">7</span>] = { <span class="hljs-number">8</span>, <span class="hljs-number">4</span>, <span class="hljs-number">4</span>, <span class="hljs-number">2</span>, <span class="hljs-number">2</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span> }; int pass; long row, col; pass = <span class="hljs-number">0</span>; <span class="hljs-keyword">while</span> (pass < <span class="hljs-number">7</span>) { row = starting_row[pass]; <span class="hljs-keyword">while</span> (row < height) { col = starting_col[pass]; <span class="hljs-keyword">while</span> (col < width) { <span class="hljs-title function_">visit</span>(row, col, <span class="hljs-title function_">min</span>(block_height[pass], height - row), <span class="hljs-title function_">min</span>(block_width[pass], width - col)); col = col + col_increment[pass]; } row = row + row_increment[pass]; } pass = pass + <span class="hljs-number">1</span>; }</code></pre> <p>The function <code>visit(row,column,height,width)</code> obtains the next transmitted pixel and paints a rectangle of the specified height and width, whose upper-left corner is at the specified row and column, using the color indicated by the pixel. Note that row and column are measured from 0,0 at the upper left corner.</p> <p>If the viewer is merging the received image with a background image, it may be more convenient just to paint the received pixel positions (the <code>visit()</code> function sets only the pixel at the specified row and column, not the whole rectangle). This produces a "fade-in" effect as the new image gradually replaces the old. An advantage of this approach is that proper alpha or transparency processing can be done as each pixel is replaced. Painting a rectangle as described above will overwrite background-image pixels that may be needed later, if the pixels eventually received for those positions turn out to be wholly or partially transparent. This is a problem only if the background image is not stored anywhere offscreen.</p> </section> <section id="13Truecolour-image-handling"><div class="header-wrapper"><h3 id="x13-11-truecolor-image-handling"><bdi class="secno">13.11 </bdi>Truecolor image handling</h3><a class="self-link" href="#13Truecolour-image-handling" aria-label="Permalink for Section 13.11"></a></div> <p>To achieve PNG's goal of universal interchangeability, decoders shall accept all types of PNG image: <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-18">indexed-color</a>, <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-23">truecolor</a>, and <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-16">greyscale</a>. Viewers running on indexed-color display hardware need to be able to reduce <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-24">truecolor</a> images to indexed-color for viewing. This process is called "color quantization".</p> <p>A simple, fast method for color quantization is to reduce the image to a fixed palette. Palettes with uniform color spacing ("color cubes") are usually used to minimize the per-pixel computation. For photograph-like images, dithering is recommended to avoid ugly contours in what should be smooth gradients; however, dithering introduces graininess that can be objectionable.</p> <p>The quality of rendering can be improved substantially by using a palette chosen specifically for the image, since a color cube usually has numerous entries that are unused in any particular image. This approach requires more work, first in choosing the palette, and second in mapping individual pixels to the closest available color. PNG allows the encoder to supply suggested palettes, but not all encoders will do so, and the suggested palettes may be unsuitable in any case (they may have too many or too few colors). Therefore, high-quality viewers will need to have a palette selection routine at hand. A large lookup table is usually the most feasible way of mapping individual pixels to palette entries with adequate speed.</p> <p>Numerous implementations of color quantization are available. The PNG sample implementation, libpng (<a href="http://www.libpng.org/pub/png/libpng.html"><code>http://www.libpng.org/pub/png/libpng.html</code></a>), includes code for the purpose.</p> </section> <section id="13Sample-depth-rescaling"><div class="header-wrapper"><h3 id="x13-12-sample-depth-rescaling"><bdi class="secno">13.12 </bdi>Sample depth rescaling</h3><a class="self-link" href="#13Sample-depth-rescaling" aria-label="Permalink for Section 13.12"></a></div> <p>Decoders may wish to scale PNG data to a lesser sample depth (data precision) for display. For example, 16-bit data will need to be reduced to 8-bit depth for use on most present-day display hardware. Reduction of 8-bit data to 5-bit depth is also common.</p> <p>The most accurate scaling is achieved by the linear equation</p> <p><code>output = floor((input * MAXOUTSAMPLE / MAXINSAMPLE) + 0.5)</code> </p> <p>where</p> <p><code>MAXINSAMPLE = (2<sup>sampledepth</sup>)-1</code><br> <code>MAXOUTSAMPLE = (2<sup>desired_sampledepth</sup>)-1</code> </p> <p>A slightly less accurate conversion is achieved by simply shifting right by <code>(sampledepth - desired_sampledepth)</code> places. For example, to reduce 16-bit samples to 8-bit, the low-order byte can be discarded. In many situations the shift method is sufficiently accurate for display purposes, and it is certainly much faster. (But if <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-13">gamma</a> correction is being done, sample rescaling can be merged into the <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-14">gamma</a> correction lookup table, as is illustrated in <a href="#13Decoder-gamma-handling" class="sec-ref"><bdi class="secno">13.13 </bdi>Decoder gamma handling</a>.)</p> <p>If the decoder needs to scale samples up (for example, if the <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-2">frame buffer</a> has a greater sample depth than the PNG image), it should use linear scaling or left-bit-replication as described in <a href="#12Sample-depth-scaling" class="sec-ref"><bdi class="secno">12.4 </bdi>Sample depth scaling</a>.</p> <p>When an <a class="chunk" href="#11sBIT">sBIT</a> chunk is present, the reference <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-25">image data</a> can be recovered by shifting right to the sample depth specified by <a class="chunk" href="#11sBIT">sBIT</a>. Note that linear scaling will not necessarily reproduce the original data, because the encoder is not required to have used linear scaling to scale the data up. However, the encoder is required to have used a method that preserves the high-order bits, so shifting always works. This is the only case in which shifting might be said to be more accurate than linear scaling. A decoder need not pay attention to the <a class="chunk" href="#11sBIT">sBIT</a> chunk; the stored image is a valid PNG datastream of the sample depth indicated by the <a class="chunk" href="#11IHDR">IHDR</a> chunk; however, using <a class="chunk" href="#11sBIT">sBIT</a> to recover the original samples before scaling them to suit the display often yields a more accurate display than ignoring <a class="chunk" href="#11sBIT">sBIT</a>.</p> <p id="tRNS-compare-exactly">When comparing pixel values to <a class="chunk" href="#11tRNS">tRNS</a> chunk values to detect transparent pixels, the comparison shall be done exactly. Therefore, transparent pixel detection shall be done before reducing sample precision.</p> </section> <section id="13Decoder-gamma-handling"><div class="header-wrapper"><h3 id="x13-13-decoder-gamma-handling"><bdi class="secno">13.13 </bdi>Decoder gamma handling</h3><a class="self-link" href="#13Decoder-gamma-handling" aria-label="Permalink for Section 13.13"></a></div> <p>See <a href="#C-GammaAppendix" class="sec-ref"><bdi class="secno">C. </bdi>Gamma and chromaticity</a> for a brief introduction to <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-15">gamma</a> issues.</p> <p>Viewers capable of full color management will perform more sophisticated calculations than those described here.</p> <p>For an image display program to produce correct tone reproduction, it is necessary to take into account the relationship between samples and display output, and the <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-17">transfer function</a> of the display system. This can be done by calculating:</p> <p><code>sample = integer_sample / (2<sup>sampledepth</sup> - 1.0)<br> display_output = sample<sup>1.0/gamma</sup><br> display_input = inverse_display_transfer(display_output)<br> framebuf_sample = floor((display_input * MAX_FRAMEBUF_SAMPLE)+0.5)</code> </p> <p>where <var>integer_sample</var> is the sample value from the datastream, <var>framebuf_sample</var> is the value to write into the <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-3">frame buffer</a>, and <var>MAX_FRAMEBUF_SAMPLE</var> is the maximum value of a <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-4">frame buffer</a> sample (255 for 8-bit, 31 for 5-bit, etc). The first line converts an integer sample into a normalized floating point value (in the range 0.0 to 1.0), the second converts to a value proportional to the desired display output intensity, the third accounts for the display system's <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-18">transfer function</a>, and the fourth converts to an integer <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-5">frame buffer</a> sample. Zero raised to any positive power is zero.</p> <p>A step could be inserted between the second and third to adjust <var>display_output</var> to account for the difference between the actual viewing conditions and the reference viewing conditions. However, this adjustment requires accounting for veiling glare, black mapping, and color appearance models, none of which can be well approximated by power functions. Such calculations are not described here. If viewing conditions are ignored, the error will usually be small.</p> <p>The display <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-19">transfer function</a> can typically be approximated by a power function with exponent <var>display_exponent</var>, in which case the second and third lines can be merged into:</p> <p><code>display_input = sample<sup>1.0/(gamma * display_exponent)</sup> = sample<sup>decoding_exponent</sup></code> </p> <p>so as to perform only one power calculation. For color images, the entire calculation is performed separately for R, G, and B values.</p> <p>The <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-18">gamma value</a> can be taken directly from the <a class="chunk" href="#11gAMA">gAMA</a> chunk. Alternatively, an application may wish to allow the user to adjust the appearance of the displayed image by influencing the <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-19">gamma value</a>. For example, the user could manually set a parameter <var>user_exponent</var> which defaults to 1.0, and the application could set:</p> <pre><code aria-busy="false" class="hljs abnf"><span class="hljs-attribute">gamma</span> <span class="hljs-operator">=</span> gamma_from_file / user_exponent decoding_exponent <span class="hljs-operator">=</span> <span class="hljs-number">1.0</span> / (gamma * display_exponent) <span class="hljs-operator">=</span> user_exponent / (gamma_from_file * display_exponent)</code></pre> <p>The user would set <var>user_exponent</var> greater than 1 to darken the mid-level tones, or less than 1 to lighten them.</p> <p>A <a class="chunk" href="#11gAMA">gAMA</a> chunk containing zero is meaningless but could appear by mistake. Decoders should ignore it, and editors may discard it and issue a warning to the user.</p> <p>It is <strong>not</strong> necessary to perform a transcendental mathematical computation for every pixel. Instead, a lookup table can be computed that gives the correct output value for every possible sample value. This requires only 256 calculations per image (for 8-bit accuracy), not one or three calculations per pixel. For an indexed-color image, a one-time correction of the palette is sufficient, unless the image uses transparency and is being displayed against a nonuniform background.</p> <p>If floating-point calculations are not possible, <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-16">gamma</a> correction tables can be computed using integer arithmetic and a precomputed table of logarithms. Example code appears in [<cite><a class="bibref" data-link-type="biblio" href="#bib-png-extensions" title="Extensions to the PNG Third Edition Specification, Version 1.6.0">PNG-EXTENSIONS</a></cite>].</p> <p>When the incoming image has unknown <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-20">gamma value</a> (<a class="chunk" href="#11gAMA">gAMA</a>, <a class="chunk" href="#srgb-standard-colour-space">sRGB</a>, and <a class="chunk" href="#11iCCP">iCCP</a> all absent), standalone image viewers should choose a likely default <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-21">gamma value</a>, but allow the user to select a new one if the result proves too dark or too light. The default <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-22">gamma value</a> may depend on other knowledge about the image, for example whether it came from the Internet or from the local system. For consistency, viewers for document formats such as HTML, or vector graphics such as SVG, should treat embedded or linked PNG images with unknown <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-23">gamma value</a> in the same way that they treat other untagged images.</p> <p>In practice, it is often difficult to determine what value of display exponent should be used. In systems with no built-in <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-17">gamma</a> correction, the display exponent is determined entirely by the <abbr title="Cathode Ray Tube">CRT</abbr>. A display exponent of 2.2 should be used unless detailed calibration measurements are available for the particular <abbr title="Cathode Ray Tube">CRT</abbr> used.</p> <p>Many modern <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-6">frame buffers</a> have lookup tables that are used to perform <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-18">gamma</a> correction, and on these systems the display exponent value should be the exponent of the lookup table and <abbr title="Cathode Ray Tube">CRT</abbr> combined. It may not be possible to find out what the lookup table contains from within the viewer application, in which case it may be necessary to ask the user to supply the display system's exponent value. Unfortunately, different manufacturers use different ways of specifying what should go into the lookup table, so interpretation of the system <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-24">gamma value</a> is system-dependent.</p> <p>The response of real displays is actually more complex than can be described by a single number (the display exponent). If actual measurements of the monitor's light output as a function of voltage input are available, the third and fourth lines of the computation above can be replaced by a lookup in these measurements, to find the actual <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-7">frame buffer</a> value that most nearly gives the desired brightness.</p> </section> <section id="13Decoder-colour-handling"><div class="header-wrapper"><h3 id="x13-14-decoder-color-handling"><bdi class="secno">13.14 </bdi>Decoder color handling</h3><a class="self-link" href="#13Decoder-colour-handling" aria-label="Permalink for Section 13.14"></a></div> <p>See <a href="#C-GammaAppendix" class="sec-ref"><bdi class="secno">C. </bdi>Gamma and chromaticity</a> for references to color issues.</p> <p>In many cases, the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-26">image data</a> in PNG datastreams will be treated as device-dependent RGB values and displayed without modification (except for appropriate <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-19">gamma</a> correction). This provides the fastest display of PNG images. But unless the viewer uses exactly the same display hardware as that used by the author of the original image, the colors will not be exactly the same as those seen by the original author, particularly for darker or near-neutral colors. The <a class="chunk" href="#11cHRM">cHRM</a> chunk provides information that allows closer color matching than that provided by <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-20">gamma</a> correction alone.</p> <p>The <a class="chunk" href="#11cHRM">cHRM</a> data can be used to transform the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-27">image data</a> from RGB to XYZ and thence into a perceptually linear color space such as CIE LAB. The colors can be partitioned to generate an optimal palette, because the geometric distance between two colors in CIE LAB is strongly related to how different those colors appear (unlike, for example, RGB or XYZ spaces). The resulting palette of colors, once transformed back into RGB color space, could be used for display or written into a <a class="chunk" href="#11PLTE">PLTE</a> chunk.</p> <p>Decoders that are part of image processing applications might also transform <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-28">image data</a> into CIE LAB space for analysis.</p> <p>In applications where color fidelity is critical, such as product design, scientific visualization, medicine, architecture, or advertising, PNG decoders can transform the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-29">image data</a> from source RGB to the display RGB space of the monitor used to view the image. This involves calculating the matrix to go from source RGB to XYZ and the matrix to go from XYZ to display RGB, then combining them to produce the overall transformation. The PNG decoder is responsible for implementing gamut mapping.</p> <p>Decoders running on platforms that have a Color Management System (CMS) can pass the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-30">image data</a>, <a class="chunk" href="#11gAMA">gAMA</a>, and <a class="chunk" href="#11cHRM">cHRM</a> values to the CMS for display or further processing.</p> <p>PNG decoders that provide color printing facilities can use the facilities in Level 2 PostScript to specify <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-31">image data</a> in calibrated RGB space or in a device-independent color space such as XYZ. This will provide better color fidelity than a simple RGB to CMYK conversion. The PostScript Language Reference manual [<cite><a class="bibref" data-link-type="biblio" href="#bib-postscript" title="PostScript Language Reference Manual">PostScript</a></cite>] gives examples. Such decoders are responsible for implementing gamut mapping between source RGB (specified in the <a class="chunk" href="#11cHRM">cHRM</a> chunk) and the target printer. The PostScript interpreter is then responsible for producing the required colors.</p> <p>PNG decoders can use the <a class="chunk" href="#11cHRM">cHRM</a> data to calculate an accurate greyscale representation of a color image. Conversion from RGB to grey is simply a case of calculating the Y (luminance) component of XYZ, which is a weighted sum of R, G, and B values. The weights depend upon the monitor type, i.e. the values in the <a class="chunk" href="#11cHRM">cHRM</a> chunk. PNG decoders may wish to do this for PNG datastreams with no <a class="chunk" href="#11cHRM">cHRM</a> chunk. In this case, a reasonable default would be the CCIR 709 primaries [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.709" title="ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange">ITU-R-BT.709</a></cite>]. The original NTSC primaries should <strong>not</strong> be used unless the PNG image really was color-balanced for such a monitor.</p> </section> <section id="13Background-colour"><div class="header-wrapper"><h3 id="x13-15-background-color"><bdi class="secno">13.15 </bdi>Background color</h3><a class="self-link" href="#13Background-colour" aria-label="Permalink for Section 13.15"></a></div> <p>The background color given by the <a class="chunk" href="#11bKGD">bKGD</a> chunk will typically be used to fill unused screen space around the image, as well as any transparent pixels within the image. (Thus, <a class="chunk" href="#11bKGD">bKGD</a> is valid and useful even when the image does not use transparency.) If no <a class="chunk" href="#11bKGD">bKGD</a> chunk is present, the viewer will need to decide upon a suitable background color. When no other information is available, a medium grey such as 153 in the 8-bit sRGB color space would be a reasonable choice. Transparent black or white text and dark drop shadows, which are common, would all be legible against this background.</p> <p>Viewers that have a specific background against which to present the image (such as web browsers) should ignore the <a class="chunk" href="#11bKGD">bKGD</a> chunk, in effect overriding <a class="chunk" href="#11bKGD">bKGD</a> with their preferred background color or background image.</p> <p>The background color given by the <a class="chunk" href="#11bKGD">bKGD</a> chunk is not to be considered transparent, even if it happens to match the color given by the <a class="chunk" href="#11tRNS">tRNS</a> chunk (or, in the case of an <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-19">indexed-color</a> image, refers to a palette index that is marked as transparent by the <a class="chunk" href="#11tRNS">tRNS</a> chunk). Otherwise one would have to imagine something "behind the background" to <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-10">composite</a> against. The background color is either used as background or ignored; it is not an intermediate layer between the PNG image and some other background.</p> <p>Indeed, it will be common that the <a class="chunk" href="#11bKGD">bKGD</a> and <a class="chunk" href="#11tRNS">tRNS</a> chunks specify the same color, since then a decoder that does not implement transparency processing will give the intended display, at least when no partially-transparent pixels are present.</p> </section> <section id="13Alpha-channel-processing"><div class="header-wrapper"><h3 id="x13-16-alpha-channel-processing"><bdi class="secno">13.16 </bdi>Alpha channel processing</h3><a class="self-link" href="#13Alpha-channel-processing" aria-label="Permalink for Section 13.16"></a></div> <p>The alpha channel can be used to <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-11">composite</a> a foreground image against a background image. The PNG datastream defines the foreground image and the transparency mask, but not the background image. PNG decoders are <strong>not</strong> required to support this most general case. It is expected that most will be able to support compositing against a single background color.</p> <p>The equation for computing a <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-12">composited</a> sample value is:</p> <pre aria-busy="false"><code class="hljs">output = alpha * foreground + (1-alpha) * background</code></pre> <p>where alpha and the input and output sample values are expressed as fractions in the range 0 to 1. This computation should be performed with intensity samples (not <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-21">gamma</a>-encoded samples). For color images, the computation is done separately for R, G, and B samples.</p> <p>The following code illustrates the general case of compositing a foreground image against a background image. It assumes that the original pixel data are available for the background image, and that output is to a <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-8">frame buffer</a> for display. Other variants are possible; see the comments below the code. The code allows the sample depths and <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-25">gamma values</a> of foreground image and background image all to be different and not necessarily suited to the display system. In practice no assumptions about equality should be made without first checking.</p> <p>This code is ISO C [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso_9899" title="ISO/IEC 9899:2018 Information technology — Programming languages — C">ISO_9899</a></cite>], with line numbers added for reference in the comments below.</p> <pre aria-busy="false"><code class="hljs javascript"><span class="hljs-number">01</span> int foreground[<span class="hljs-number">4</span>]; <span class="hljs-comment">/* image pixel: R, G, B, A */</span> <span class="hljs-number">02</span> int background[<span class="hljs-number">3</span>]; <span class="hljs-comment">/* background pixel: R, G, B */</span> <span class="hljs-number">03</span> int fbpix[<span class="hljs-number">3</span>]; <span class="hljs-comment">/* frame buffer pixel */</span> <span class="hljs-number">04</span> int fg_maxsample; <span class="hljs-comment">/* foreground max sample */</span> <span class="hljs-number">05</span> int bg_maxsample; <span class="hljs-comment">/* background max sample */</span> <span class="hljs-number">06</span> int fb_maxsample; <span class="hljs-comment">/* frame buffer max sample */</span> <span class="hljs-number">07</span> int ialpha; <span class="hljs-number">08</span> float alpha, compalpha; <span class="hljs-number">09</span> float gamfg, linfg, gambg, linbg, comppix, gcvideo; <span class="hljs-comment">/* Get max sample values in data and frame buffer */</span> <span class="hljs-number">10</span> fg_maxsample = (<span class="hljs-number">1</span> << fg_sample_depth) - <span class="hljs-number">1</span>; <span class="hljs-number">11</span> bg_maxsample = (<span class="hljs-number">1</span> << bg_sample_depth) - <span class="hljs-number">1</span>; <span class="hljs-number">12</span> fb_maxsample = (<span class="hljs-number">1</span> << frame_buffer_sample_depth) - <span class="hljs-number">1</span>; <span class="hljs-comment">/* * Get integer version of alpha. * Check for opaque and transparent special cases; * no compositing needed if so. * * We show the whole gamma decode/correct process in * floating point, but it would more likely be done * with lookup tables. */</span> <span class="hljs-number">13</span> ialpha = foreground[<span class="hljs-number">3</span>]; <span class="hljs-number">14</span> <span class="hljs-keyword">if</span> (ialpha == <span class="hljs-number">0</span>) { <span class="hljs-comment">/* * Foreground image is transparent here. * If the background image is already in the frame * buffer, there is nothing to do. */</span> <span class="hljs-number">15</span> ; <span class="hljs-number">16</span> } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (ialpha == fg_maxsample) { <span class="hljs-comment">/* * Copy foreground pixel to frame buffer. */</span> <span class="hljs-number">17</span> <span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i < <span class="hljs-number">3</span>; i++) { <span class="hljs-number">18</span> gamfg = (float) foreground[i] / fg_maxsample; <span class="hljs-number">19</span> linfg = <span class="hljs-title function_">pow</span>(gamfg, <span class="hljs-number">1.0</span> / fg_gamma); <span class="hljs-number">20</span> comppix = linfg; <span class="hljs-number">21</span> gcvideo = <span class="hljs-title function_">pow</span>(comppix, <span class="hljs-number">1.0</span> / display_exponent); <span class="hljs-number">22</span> fbpix[i] = (int) (gcvideo * fb_maxsample + <span class="hljs-number">0.5</span>); <span class="hljs-number">23</span> } <span class="hljs-number">24</span> } <span class="hljs-keyword">else</span> { <span class="hljs-comment">/* * Compositing is necessary. * Get floating-point alpha and its complement. * Note: alpha is always linear; gamma does not * affect it. */</span> <span class="hljs-number">25</span> alpha = (float) ialpha / fg_maxsample; <span class="hljs-number">26</span> compalpha = <span class="hljs-number">1.0</span> - alpha; <span class="hljs-number">27</span> <span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i < <span class="hljs-number">3</span>; i++) { <span class="hljs-comment">/* * Convert foreground and background to floating * point, then undo gamma encoding. */</span> <span class="hljs-number">28</span> gamfg = (float) foreground[i] / fg_maxsample; <span class="hljs-number">29</span> linfg = <span class="hljs-title function_">pow</span>(gamfg, <span class="hljs-number">1.0</span> / fg_gamma); <span class="hljs-number">30</span> gambg = (float) background[i] / bg_maxsample;</code></pre> <pre aria-busy="false"><code class="hljs javascript"><span class="hljs-number">31</span> linbg = <span class="hljs-title function_">pow</span>(gambg, <span class="hljs-number">1.0</span> / bg_gamma); <span class="hljs-comment">/* * Composite. */</span> <span class="hljs-number">32</span> comppix = linfg * alpha + linbg * compalpha; <span class="hljs-comment">/* * Gamma correct for display. * Convert to integer frame buffer pixel. */</span> <span class="hljs-number">33</span> gcvideo = <span class="hljs-title function_">pow</span>(comppix, <span class="hljs-number">1.0</span> / display_exponent); <span class="hljs-number">34</span> fbpix[i] = (int) (gcvideo * fb_maxsample + <span class="hljs-number">0.5</span>); <span class="hljs-number">35</span> } <span class="hljs-number">36</span> }</code></pre> <p>Variations:</p> <ol> <li>If output is to another PNG datastream instead of a <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-9">frame buffer</a>, lines 21, 22, 33, and 34 should be changed along the following lines <pre aria-busy="false"><code class="hljs javascript"><span class="hljs-comment">/* * Gamma encode for storage in output datastream. * Convert to integer sample value. */</span> gamout = <span class="hljs-title function_">pow</span>(comppix, outfile_gamma); outpix[i] = (int) (gamout * out_maxsample + <span class="hljs-number">0.5</span>);</code></pre>Also, it becomes necessary to process background pixels when alpha is zero, rather than just skipping pixels. Thus, line 15 will need to be replaced by copies of lines 17-23, but processing background instead of foreground pixel values. </li> <li>If the sample depths of the output file, foreground file, and background file are all the same, and the three <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-26">gamma values</a> also match, then the no-compositing code in lines 14-23 reduces to copying pixel values from the input file to the output file if alpha is one, or copying pixel values from background to output file if alpha is zero. Since alpha is typically either zero or one for the vast majority of pixels in an image, this is a significant saving. No <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-22">gamma</a> computations are needed for most pixels. </li> <li>When the sample depths and <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-27">gamma values</a> all match, it may appear attractive to skip the <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-23">gamma</a> decoding and encoding (lines 28-31, 33-34) and just perform line 32 using <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-24">gamma</a>-encoded sample values. Although this does not have too bad an effect on image quality, the time savings are small if alpha values of zero and one are treated as special cases as recommended here. </li> <li>If the original pixel values of the background image are no longer available, only processed <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-10">frame buffer</a> pixels left by display of the background image, then lines 30 and 31 need to extract intensity from the <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-11">frame buffer</a> pixel values using code such as <pre aria-busy="false"><code class="hljs javascript"><span class="hljs-comment">/* * Convert frame buffer value into intensity sample. */</span> gcvideo = (float) fbpix[i] / fb_maxsample; linbg = <span class="hljs-title function_">pow</span>(gcvideo, display_exponent);</code></pre>However, some roundoff error can result, so it is better to have the original background pixels available if at all possible. </li> <li>Note that lines 18-22 are performing exactly the same <a href="#dfn-gamma" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-25">gamma</a> computation that is done when no alpha channel is present. If the no-alpha case is handled with a lookup table, the same lookup table can be used here. Lines 28-31 and 33-34 can also be done with (different) lookup tables. </li> <li>Integer arithmetic can be used instead of floating point, providing care is taken to maintain sufficient precision throughout.</li> </ol> <div class="note" role="note" id="issue-container-generatedID-22"><div role="heading" class="note-title marker" id="h-note-22" aria-level="4"><span>Note</span></div><p class="">NOTE In floating point, no overflow or underflow checks are needed, because the input sample values are guaranteed to be between 0 and 1, and compositing always yields a result that is in between the input values (inclusive). With integer arithmetic, some roundoff-error analysis might be needed to guarantee no overflow or underflow.</p></div> <p>When displaying a PNG image with full alpha channel, it is important to be able to <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-13">composite</a> the image against some background, even if it is only black. Ignoring the alpha channel will cause PNG images that have been converted from an associated-alpha representation to look wrong. (Of course, if the alpha channel is a separate transparency mask, then ignoring alpha is a useful option: it allows the hidden parts of the image to be recovered.)</p> <p>Even if the decoder does not implement true compositing logic, it is simple to deal with images that contain only zero and one alpha values. (This is implicitly true for <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-17">greyscale</a> and <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-25">truecolor</a> PNG datastreams that use a <a class="chunk" href="#11tRNS">tRNS</a> chunk; for <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-20">indexed-color</a> PNG datastreams it is easy to check whether the <a class="chunk" href="#11tRNS">tRNS</a> chunk contains any values other than 0 and 255.) In this simple case, transparent pixels are replaced by the background color, while others are unchanged.</p> <p>If a decoder contains only this much transparency capability, it should deal with a full alpha channel by treating all nonzero alpha values as fully opaque or by dithering. Neither approach will yield very good results for images converted from associated-alpha formats, but this is preferable to doing nothing. Dithering full alpha to binary alpha is very much like dithering greyscale to black-and-white, except that all fully transparent and fully opaque pixels should be left unchanged by the dither.</p> </section> <section id="13Histogram-and-suggested-palette-usage"><div class="header-wrapper"><h3 id="x13-17-histogram-and-suggested-palette-usage"><bdi class="secno">13.17 </bdi>Histogram and suggested palette usage</h3><a class="self-link" href="#13Histogram-and-suggested-palette-usage" aria-label="Permalink for Section 13.17"></a></div> <p>For viewers running on indexed-color hardware attempting to display a <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-26">truecolor</a> image, or an indexed-color image whose palette is too large for the <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-12">frame buffer</a>, the encoder may have provided one or more suggested palettes in <a class="chunk" href="#11sPLT">sPLT</a> chunks. If one of these is found to be suitable, based on size and perhaps name, the PNG decoder can use that palette. Suggested palettes with a sample depth different from what the decoder needs can be converted using sample depth rescaling (see <a href="#13Sample-depth-rescaling" class="sec-ref"><bdi class="secno">13.12 </bdi>Sample depth rescaling</a>).</p> <p>When the background is a solid color, the viewer should <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-14">composite</a> the image and the suggested palette against that color, then quantize the resulting image to the resulting RGB palette. When the image uses transparency and the background is not a solid color, no suggested palette is likely to be useful.</p> <p>For <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-27">truecolor</a> images, a suggested palette might also be provided in a <a class="chunk" href="#11PLTE">PLTE</a> chunk. If the image has a <a class="chunk" href="#11tRNS">tRNS</a> chunk and the background is a solid color, the viewer will need to adapt the suggested palette for use with its desired background color. To do this, the palette entry closest to the <a class="chunk" href="#11tRNS">tRNS</a> color should be replaced with the desired background color; or alternatively a palette entry for the background color can be added, if the viewer can handle more colors than there are <a class="chunk" href="#11PLTE">PLTE</a> entries.</p> <p>For images of <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-41">color type</a> 6 (<a href="#dfn-truecolor-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-truecolor-with-alpha-7">truecolor with alpha</a>), any <a class="chunk" href="#11PLTE">PLTE</a> chunk should have been designed for display of the image against a uniform background of the color specified by the <a class="chunk" href="#11bKGD">bKGD</a> chunk. Viewers should probably ignore the palette if they intend to use a different background, or if the <a class="chunk" href="#11bKGD">bKGD</a> chunk is missing. Viewers can use a suggested palette for display against a different background than it was intended for, but the results may not be very good.</p> <p>If the viewer presents a transparent <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-28">truecolor</a> image against a background that is more complex than a uniform color, it is unlikely that the suggested palette will be optimal for the <a href="#dfn-composited" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-composited-15">composite</a> image. In this case it is best to perform a <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-29">truecolor</a> compositing step on the <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-30">truecolor</a> PNG image and background image, then color-quantize the resulting image.</p> <p>In <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-31">truecolor</a> PNG datastreams, if both <a class="chunk" href="#11PLTE">PLTE</a> and <a class="chunk" href="#11sPLT">sPLT</a> chunks appear, the PNG decoder may choose from among the palettes suggested by both, bearing in mind the different transparency semantics described above.</p> <p>The frequencies in the <a class="chunk" href="#11sPLT">sPLT</a> and <a class="chunk" href="#11hIST">hIST</a> chunks are useful when the viewer cannot provide as many colors as are used in the palette in the PNG datastream. If the viewer has a shortfall of only a few colors, it is usually adequate to drop the least-used colors from the palette. To reduce the number of colors substantially, it is best to choose entirely new representative colors, rather than trying to use a subset of the existing palette. This amounts to performing a new color quantization step; however, the existing palette and histogram can be used as the input data, thus avoiding a scan of the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-32">image data</a> in the <a class="chunk" href="#11IDAT">IDAT</a> chunks.</p> <p>If no suggested palette is provided, a decoder can develop its own, at the cost of an extra pass over the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-33">image data</a> in the <a class="chunk" href="#11IDAT">IDAT</a> chunks. Alternatively, a default palette (probably a color cube) can be used.</p> <p>See also <a href="#12Suggested-palettes" class="sec-ref"><bdi class="secno">12.5 </bdi>Suggested palettes</a>.</p> </section> </section> <section id="14EditorsExt"><div class="header-wrapper"><h2 id="x14-editors"><bdi class="secno">14. </bdi>Editors</h2><a class="self-link" href="#14EditorsExt" aria-label="Permalink for Section 14."></a></div> <section id="14Additional-chunk-types"><div class="header-wrapper"><h3 id="x14-1-additional-chunk-types"><bdi class="secno">14.1 </bdi>Additional chunk types</h3><a class="self-link" href="#14Additional-chunk-types" aria-label="Permalink for Section 14.1"></a></div> <p>Authors are encouraged to look existing chunk types in both this specification and [<cite><a class="bibref" data-link-type="biblio" href="#bib-png-extensions" title="Extensions to the PNG Third Edition Specification, Version 1.6.0">PNG-EXTENSIONS</a></cite>] before considering introducing a new chunk types. The chunk types at [<cite><a class="bibref" data-link-type="biblio" href="#bib-png-extensions" title="Extensions to the PNG Third Edition Specification, Version 1.6.0">PNG-EXTENSIONS</a></cite>] are expected to be less widely supported than those defined in this specification.</p> </section> <section id="14Ordering"><div class="header-wrapper"><h3 id="x14-2-behavior-of-png-editors"><bdi class="secno">14.2 </bdi>Behavior of PNG editors</h3><a class="self-link" href="#14Ordering" aria-label="Permalink for Section 14.2"></a></div> <p>Two examples of <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-7">PNG editors</a> are a program that adds or modifies text chunks, and a program that adds a suggested palette to a <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-32">truecolor</a> PNG datastream. Ordinary image editors are not <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-8">PNG editors</a> because they usually discard all unrecognized information while reading in an image.</p> <p>To allow new chunk types to be added to PNG, it is necessary to establish rules about the ordering requirements for all chunk types. Otherwise a <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-9">PNG editor</a> does not know what to do when it encounters an unknown chunk.</p> <p>EXAMPLE Consider a hypothetical new ancillary chunk type that is safe-to-copy and is required to appear after <a class="chunk" href="#11PLTE">PLTE</a> if <a class="chunk" href="#11PLTE">PLTE</a> is present. If a program attempts to add a <a class="chunk" href="#11PLTE">PLTE</a> chunk and does not recognize the new chunk, it may insert the <a class="chunk" href="#11PLTE">PLTE</a> chunk in the wrong place, namely after the new chunk. Such problems could be prevented by requiring <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-10">PNG editors</a> to discard all unknown chunks, but that is a very unattractive solution. Instead, PNG requires ancillary chunks not to have ordering restrictions like this.</p> <p>To prevent this type of problem while allowing for future extension, constraints are placed on both the behavior of <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-11">PNG editors</a> and the allowed ordering requirements for chunks. The safe-to-copy bit defines the proper handling of unrecognized chunks in a datastream that is being modified.</p> <ol> <li>If a chunk's safe-to-copy bit is 1, the chunk may be copied to a modified PNG datastream whether or not the <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-12">PNG editor</a> recognizes the chunk type, and regardless of the extent of the datastream modifications. </li> <li>If a chunk's safe-to-copy bit is 0, it indicates that the chunk depends on the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-34">image data</a>. If the program has made <strong>any</strong> changes to <strong>critical</strong> chunks, including addition, modification, deletion, or reordering of critical chunks, then unrecognized unsafe chunks shall <strong>not</strong> be copied to the output PNG datastream. (Of course, if the program <strong>does</strong> recognize the chunk, it can choose to output an appropriately modified version.) </li> <li>A <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-13">PNG editor</a> is always allowed to copy all unrecognized ancillary chunks if it has only added, deleted, modified, or reordered <strong>ancillary</strong> chunks. This implies that it is not permissible for ancillary chunks to depend on other ancillary chunks. </li> <li> <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-14">PNG editors</a> shall terminate on encountering an unrecognized critical chunk type, because there is no way to be certain that a valid datastream will result from modifying a datastream containing such a chunk. (Simply discarding the chunk is not good enough, because it might have unknown implications for the interpretation of other chunks.) The safe/unsafe mechanism is intended for use with ancillary chunks. The safe-to-copy bit will always be 0 for critical chunks. </li> </ol> <p>The rules governing ordering of chunks are as follows.</p> <ol> <li>When copying an unknown <strong>unsafe-to-copy</strong> ancillary chunk, a <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-15">PNG editor</a> shall not move the chunk relative to any critical chunk. It may relocate the chunk freely relative to other ancillary chunks that occur between the same pair of critical chunks. (This is well defined since the editor shall not add, delete, modify, or reorder critical chunks if it is preserving unknown unsafe-to-copy chunks.) </li> <li>When copying an unknown <strong>safe-to-copy</strong> ancillary chunk, a <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-16">PNG editor</a> shall not move the chunk from before <a class="chunk" href="#11IDAT">IDAT</a> to after <a class="chunk" href="#11IDAT">IDAT</a> or vice versa. (This is well defined because <a class="chunk" href="#11IDAT">IDAT</a> is always present.) Any other reordering is permitted. </li> <li>When copying a <strong>known</strong> ancillary chunk type, an editor need only honour the specific chunk ordering rules that exist for that chunk type. However, it may always choose to apply the above general rules instead.</li> </ol> <p>These rules are expressed in terms of copying chunks from an input datastream to an output datastream, but they apply in the obvious way if a PNG datastream is modified in place.</p> <p>See also <a href="#5Chunk-naming-conventions" class="sec-ref"><bdi class="secno">5.4 </bdi>Chunk naming conventions</a>.</p> <p><a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-17">PNG editors</a> that do not change the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-35">image data</a> should not change the <a class="chunk" href="#11tIME">tIME</a> chunk. The Creation Time keyword in the <a class="chunk" href="#11tEXt">tEXt</a>, <a class="chunk" href="#11zTXt">zTXt</a>, and <a class="chunk" href="#11iTXt">iTXt</a> chunks may be used for a user-supplied time.</p> </section> <section id="14Ordering-of-chunks"><div class="header-wrapper"><h3 id="x14-3-ordering-of-chunks"><bdi class="secno">14.3 </bdi>Ordering of chunks</h3><a class="self-link" href="#14Ordering-of-chunks" aria-label="Permalink for Section 14.3"></a></div> <section id="14Ordering-of-critical-chunks"><div class="header-wrapper"><h4 id="x14-3-1-ordering-of-critical-chunks"><bdi class="secno">14.3.1 </bdi>Ordering of critical chunks</h4><a class="self-link" href="#14Ordering-of-critical-chunks" aria-label="Permalink for Section 14.3.1"></a></div> <p>Critical chunks may have arbitrary ordering requirements, because <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-18">PNG editors</a> are required to terminate if they encounter unknown critical chunks. For example <a class="chunk" href="#11IHDR">IHDR</a> has the specific ordering rule that it shall always appear first. A PNG editor, or indeed any PNG-writing program, shall know and follow the ordering rules for any critical chunk type that it can generate.</p> </section> <section id="14Ordering-of-ancillary-chunks"><div class="header-wrapper"><h4 id="x14-3-2-ordering-of-ancillary-chunks"><bdi class="secno">14.3.2 </bdi>Ordering of ancillary chunks</h4><a class="self-link" href="#14Ordering-of-ancillary-chunks" aria-label="Permalink for Section 14.3.2"></a></div> <p>The strictest ordering rules for an ancillary chunk type are:</p> <ol> <li>Unsafe-to-copy chunks may have ordering requirements relative to critical chunks.</li> <li>Safe-to-copy chunks may have ordering requirements relative to <a class="chunk" href="#11IDAT">IDAT</a>. </li> </ol> <p>The actual ordering rules for any particular ancillary chunk type may be weaker. See for example the ordering rules for the standard ancillary chunk types in <a href="#5ChunkOrdering" class="sec-ref"><bdi class="secno">5.6 </bdi>Chunk ordering</a>.</p> <p>Decoders shall not assume more about the positioning of any ancillary chunk than is specified by the chunk ordering rules. In particular, it is never valid to assume that a specific ancillary chunk type occurs with any particular positioning relative to other ancillary chunks.</p> <p>EXAMPLE It is unsafe to assume that a particular private ancillary chunk occurs immediately before <a class="chunk" href="#11IEND">IEND</a>. Even if it is always written in that position by a particular application, a <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-19">PNG editor</a> might have inserted some other ancillary chunk after it. But it is safe to assume that the chunk will remain somewhere between <a class="chunk" href="#11IDAT">IDAT</a> and <a class="chunk" href="#11IEND">IEND</a>.</p> </section> </section> </section> <div id="15Conformance"> </div> <section id="conformance"><div class="header-wrapper"><h2 id="x15-conformance"><bdi class="secno">15. </bdi>Conformance</h2><a class="self-link" href="#conformance" aria-label="Permalink for Section 15."></a></div><p>As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.</p><p> The key words <em class="rfc2119">MAY</em>, <em class="rfc2119">MUST</em>, <em class="rfc2119">SHALL</em>, <em class="rfc2119">SHOULD</em>, and <em class="rfc2119">SHOULD NOT</em> in this document are to be interpreted as described in <a href="https://datatracker.ietf.org/doc/html/bcp14">BCP 14</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc2119" title="Key words for use in RFCs to Indicate Requirement Levels">RFC2119</a></cite>] [<cite><a class="bibref" data-link-type="biblio" href="#bib-rfc8174" title="Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words">RFC8174</a></cite>] when, and only when, they appear in all capitals, as shown here. </p> <section id="conformance-0"><div class="header-wrapper"><h3 id="x15-1-conformance"><bdi class="secno">15.1 </bdi>Conformance</h3><a class="self-link" href="#conformance-0" aria-label="Permalink for Section 15.1"></a></div> </section><section id="15ConfIntro"><div class="header-wrapper"><h3 id="x15-2-introduction"><bdi class="secno">15.2 </bdi>Introduction</h3><a class="self-link" href="#15ConfIntro" aria-label="Permalink for Section 15.2"></a></div> <section id="15ConfObjectives"><div class="header-wrapper"><h4 id="x15-2-1-objectives"><bdi class="secno">15.2.1 </bdi>Objectives</h4><a class="self-link" href="#15ConfObjectives" aria-label="Permalink for Section 15.2.1"></a></div> <p>This clause addresses conformance of PNG datastreams, PNG encoders, PNG decoders, and <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-20">PNG editors</a>.</p> <p>The primary objectives of the specifications in this clause are:</p> <ol> <li>to promote interoperability by eliminating arbitrary subsets of, or extensions to, this specification;</li> <li>to promote uniformity in the development of conformance tests;</li> <li>to promote consistent results across PNG encoders, decoders, and editors;</li> <li>to facilitate automated test generation.</li> </ol> </section> <section id="15ConfScope"><div class="header-wrapper"><h4 id="x15-2-2-scope"><bdi class="secno">15.2.2 </bdi>Scope</h4><a class="self-link" href="#15ConfScope" aria-label="Permalink for Section 15.2.2"></a></div> <p>Conformance is defined for PNG datastreams and for PNG encoders, decoders, and editors.</p> <p>This clause addresses the PNG datastream and implementation requirements including the range of allowable differences for PNG encoders, PNG decoders, and <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-21">PNG editors</a>. This clause does not directly address the environmental, performance, or resource requirements of the encoder, decoder, or editor.</p> <p>The scope of this clause is limited to rules for the open interchange of PNG datastreams.</p> </section> </section> <section id="15ConformanceConf"><div class="header-wrapper"><h3 id="x15-3-conformance-conditions"><bdi class="secno">15.3 </bdi>Conformance conditions</h3><a class="self-link" href="#15ConformanceConf" aria-label="Permalink for Section 15.3"></a></div> <section id="15FileConformance"><div class="header-wrapper"><h4 id="x15-3-1-conformance-of-png-datastreams"><bdi class="secno">15.3.1 </bdi>Conformance of PNG datastreams</h4><a class="self-link" href="#15FileConformance" aria-label="Permalink for Section 15.3.1"></a></div> <p>A PNG datastream conforms to this specification if the following conditions are met.</p> <ol> <li>The PNG datastream contains a PNG signature as the first content (see <a href="#5PNG-file-signature" class="sec-ref"><bdi class="secno">5.2 </bdi>PNG signature</a>). </li> <li>With respect to the chunk types defined in this International Standard: <ul> <li>the PNG datastream contains as its first chunk, an <a class="chunk" href="#11IHDR">IHDR</a> chunk, immediately following the PNG signature; </li> <li>the PNG datastream contains as its last chunk, an <a class="chunk" href="#11IEND">IEND</a> chunk. </li> </ul> </li> <li>No chunks or other content follow the <a class="chunk" href="#11IEND">IEND</a> chunk. </li> <li>All chunks contained therein match the specification of the corresponding chunk types of this specification. The PNG datastream shall obey the relationships among chunk types defined in this specification.</li> <li>The sequence of chunks in the PNG datastream obeys the ordering relationship specified in this International Standard.</li> <li>All field values in the PNG datastream obey the relationships specified in this specification producing the structure specified in this specification.</li> <li>No chunks appear in the PNG datastream other than those specified in this specification or those defined according to the rules for creating new chunk types as defined in this specification.</li> <li>The PNG datastream is encoded according to the rules of this International Standard.</li> </ol> </section> <section id="15ConformanceEncoder"><div class="header-wrapper"><h4 id="x15-3-2-conformance-of-png-encoders"><bdi class="secno">15.3.2 </bdi>Conformance of PNG encoders</h4><a class="self-link" href="#15ConformanceEncoder" aria-label="Permalink for Section 15.3.2"></a></div> <p>A PNG encoder conforms to this specification if it satisfies the following conditions.</p> <ol> <li>All PNG datastreams that are generated by the PNG encoder are conforming PNG datastreams.</li> <li>When encoding input samples that have a sample depth that cannot be directly represented in PNG, the encoder scales the samples up to the next higher sample depth that is allowed by PNG. The data are scaled in such a way that the high-order bits match the original data.</li> <li> <a href="#dfn-private-field-values" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-private-field-values-5">Private field values</a> are used when encoding experimental or private definitions of values for any of the method or type fields. </li> </ol> </section> <section id="15ConformanceDecoder"><div class="header-wrapper"><h4 id="x15-3-3-conformance-of-png-decoders"><bdi class="secno">15.3.3 </bdi>Conformance of PNG decoders</h4><a class="self-link" href="#15ConformanceDecoder" aria-label="Permalink for Section 15.3.3"></a></div> <p>A PNG decoder conforms to this specification if it satisfies the following conditions.</p> <ol> <li>It is able to read any PNG datastream that conforms to this International Standard, including both public and private chunks whose types may not be recognized.</li> <li>It supports all the standardized critical chunks, and all the standardized compression, filter, and interlace methods and types in any PNG datastream that conforms to this International Standard.</li> <li>Unknown chunk types are handled as described in <a href="#5Chunk-naming-conventions" class="sec-ref"><bdi class="secno">5.4 </bdi>Chunk naming conventions</a>. An unknown chunk type is <strong>not</strong> treated as an error unless it is a critical chunk. </li> <li>Unexpected values in fields of known chunks (for example, an unexpected compression method in the <a class="chunk" href="#11IHDR">IHDR</a> chunk) are treated as errors. </li> <li>All types of PNG images (indexed-color, <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-33">truecolor</a>, <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-18">greyscale</a>, <a href="#dfn-truecolor-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-truecolor-with-alpha-8">truecolor with alpha</a>, and <a href="#dfn-greyscale-with-alpha" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-with-alpha-4">greyscale with alpha</a>) are processed. For example, decoders which are part of viewers running on indexed-color display hardware shall reduce <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-34">truecolor</a> images to indexed format for viewing. </li> <li>Encountering an unknown chunk in which the ancillary bit is 0 generates an error if the decoder is attempting to extract the image.</li> <li>A chunk type in which the reserved bit is set is treated as an unknown chunk type.</li> <li>All valid combinations of bit depth and <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-42">color type</a> as defined in <a class="chunk sec-ref" href="#11IHDR"><bdi class="secno">11.2.1 </bdi><span class="chunk">IHDR</span> Image header</a> are supported. </li> <li>An error is reported if an unrecognized value is encountered in the bit depth, <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-43">color type</a>, compression method, <a href="#3filter" class="internalDFN" data-link-type="dfn" id="ref-for-3filter-14">filter method</a>, or interlace method bytes of the <a class="chunk" href="#11IHDR">IHDR</a> chunk. </li> <li>When processing 16-bit <a href="#dfn-greyscale" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-greyscale-19">greyscale</a> or <a href="#3truecolour" class="internalDFN" data-link-type="dfn" id="ref-for-3truecolour-35">truecolor</a> data in the <a class="chunk" href="#11tRNS">tRNS</a> chunk, both bytes of the sample values are evaluated to determine whether a pixel is transparent. </li> <li>When processing an image compressed by compression method 0, the decoder assumes no more than that the complete <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-36">image data</a> is represented by a single compressed datastream that is stored in some number of <a class="chunk" href="#11IDAT">IDAT</a> chunks. </li> <li>No assumptions are made concerning the positioning of any ancillary chunk other than those that are specified by the chunk ordering rules.</li> </ol> </section> <section id="15ConformanceEditor"><div class="header-wrapper"><h4 id="x15-3-4-conformance-of-png-editors"><bdi class="secno">15.3.4 </bdi>Conformance of PNG editors</h4><a class="self-link" href="#15ConformanceEditor" aria-label="Permalink for Section 15.3.4"></a></div> <p>A <a href="#dfn-png-editor" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-png-editor-22">PNG editor</a> conforms to this specification if it satisfies the following conditions.</p> <ol> <li>It conforms to the requirements for PNG encoders.</li> <li>It conforms to the requirements for PNG decoders.</li> <li>It is able to encode all chunks that it decodes.</li> <li>It preserves the ordering of the chunks presented within the rules in <a href="#5ChunkOrdering" class="sec-ref"><bdi class="secno">5.6 </bdi>Chunk ordering</a>. </li> <li>It properly processes the safe-to-copy bit information and preserves unknown chunks when the safe-to-copy rules permit it.</li> <li>Unless the user specifically permits lossy operations or the editor issues a warning, it preserves all information required to reconstruct the reference image exactly, except that the sample depth of the alpha channel need not be preserved if it contains only zero and maximum values. Operations such as changing the <a href="#3colourType" class="internalDFN" data-link-type="dfn" id="ref-for-3colourType-44">color type</a> or rearranging the palette in an <a href="#3indexedColour" class="internalDFN" data-link-type="dfn" id="ref-for-3indexedColour-21">indexed-color</a> datastream are permitted provided that the new datastream losslessly represents the same reference image. </li> </ol> </section> </section> </section> <section class="appendix" id="A-Conventions"><div class="header-wrapper"><h2 id="IANA-registrations"><bdi class="secno">A. </bdi>Internet Media Types</h2><a class="self-link" href="#IANA-registrations" aria-label="Permalink for Appendix A."></a></div> <section id="image-png"><div class="header-wrapper"><h3 id="A-Media-type"><bdi class="secno">A.1 </bdi>image/png</h3><a class="self-link" href="#A-Media-type" aria-label="Permalink for Appendix A.1"></a></div> <p>This updates the existing <span class="tt">image/png</span> Internet Media type, under the <span class="tt">image</span> top level type. This appendix is in conformance with <a href="https://www.rfc-editor.org/info/bcp13">BCP 13</a> and <a href="https://www.w3.org/2020/01/registering-mediatypes.html">W3CRegMedia</a>.</p> <dl> <dt>Media type name:</dt> <dd>image</dd> <dt>Media subtype name:</dt> <dd>png</dd> <dt>Required parameters:</dt> <dd>None</dd> <dt>Optional parameters:</dt> <dd>None</dd> <dt>Encoding considerations:</dt> <dd>binary</dd> <dt>Security considerations:</dt> <dd> <p>A PNG document is composed of a collection of explicitly typed "chunks". For each of the chunk types defined in the PNG specification (except for <span class="chunk">gIFx</span>), the only effect associated with those chunks is to cause an image to be rendered on the recipient's display or printer.</p> <p>The <span class="chunk">gIFx</span> chunk type is used to encapsulate Application Extension data, and some use of that data might present security risks, though no risks are known. Likewise, the security risks associated with future chunk types cannot be evaluated, particularly unregistered chunks. However, it is the intention of the PNG Working Group to disallow chunks containing "executable" data to become registered chunks.</p> <p>The text chunks, <a class="chunk" href="#11tEXt">tEXt</a>, <a class="chunk" href="#11iTXt">iTXT</a> and <a class="chunk" href="#11zTXt">zTXt</a>, contain data that can be displayed in the form of comments, etc. Some operating systems or terminals might allow the display of textual data with embedded control characters to perform operations such as re-mapping of keys, creation of files, etc. For this reason, the specification recommends that the text chunks be filtered for control characters before direct display.</p> <p>The PNG format is specifically designed to facilitate early detection of file transmission errors, and makes use of cyclical redundancy checks to ensure the integrity of the data contained in its chunks.</p> </dd> <dt>Interoperability considerations:</dt> <dd>Network byte order used throughout.</dd> <dt>Published specification:</dt> <dd> <a href="https://www.w3.org/TR/PNG/">Portable Network Graphics (PNG) Specification</a>, <a href="https://www.w3.org/TR/PNG/">https://www.w3.org/TR/PNG/</a> </dd> <dt>Applications which use this media:</dt> <dd>PNG is widely implemented in all Web browsers, image viewers, and image creation tools</dd> <dt>Fragment identifier considerations:</dt> <dd>N/A</dd> <dt>Restrictions on usage:</dt> <dd>N/A</dd> <dt>Provisional registration? (standards tree only):</dt> <dd>No</dd> <dt>Additional information:</dt> <dd> <dl> <dt>Deprecated alias names for this type:</dt> <dd>N/A</dd> <dt>Magic number(s):</dt> <dd>89 50 4E 47 0D 0A 1A 0A</dd> <dt>File extension(s):</dt> <dd>.png</dd> <dt>Macintosh file type code:</dt> <dd>PNGf</dd> <dt>Object Identifiers:</dt> <dd>N/A</dd> </dl> </dd> <dt>General Comments:</dt> <dd> <p>This registration updates the earlier one:</p> <ol> <li>The old one points to an expired Internet Draft. This updated registration points to a <abbr title="World Wide Web Consortium">W3C</abbr> Recommendation.</li> <li>The old contact person is sadly deceased. The new contact email is a publicly archived <abbr title="World Wide Web Consortium">W3C</abbr> mailing list for the PNG Working Group.</li> <li>Change controller is <abbr title="World Wide Web Consortium">W3C</abbr></li> </ol> </dd> <dt>Person to contact for further information:</dt> <dd> <dl> <dt>Name:</dt> <dd>PNG Working Group</dd> <dt>Email:</dt> <dd> <a href="mailto:public-png@w3.org">public-png@w3.org</a> </dd> </dl> </dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Author/Change controller:</dt> <dd><abbr title="World Wide Web Consortium">W3C</abbr></dd> </dl> </section> <section id="image-apng"><div class="header-wrapper"><h3 id="a-2-image-apng"><bdi class="secno">A.2 </bdi>image/apng</h3><a class="self-link" href="#image-apng" aria-label="Permalink for Appendix A.2"></a></div> <p>This appendix is in conformance with <a href="https://www.rfc-editor.org/info/bcp13">BCP 13</a> and <a href="https://www.w3.org/2020/01/registering-mediatypes.html">W3CRegMedia</a>.</p> <dl> <dt>Media type name:</dt> <dd>image</dd> <dt>Media subtype name:</dt> <dd>apng</dd> <dt>Required parameters:</dt> <dd>N/A</dd> <dt>Optional parameters:</dt> <dd>N/A</dd> <dt>Encoding considerations:</dt> <dd>binary</dd> <dt>Security considerations:</dt> <dd> <p>An <abbr title="Animated PNG">APNG</abbr> document is composed of a collection of explicitly typed "chunks". For each of the chunk types defined in the PNG specification (except for <span class="chunk">gIFx</span>), the only effect associated with those chunks is to cause an animated image to be rendered on the recipient's display.</p> <p>The <span class="chunk">gIFx</span> chunk type is used to encapsulate Application Extension data, and some use of that data might present security risks, though no risks are known. Likewise, the security risks associated with future chunk types cannot be evaluated, particularly unregistered chunks. However, it is the intention of the PNG Working Group to disallow chunks containing "executable" data to become registered chunks.</p> <p>The text chunks, <a class="chunk" href="#11tEXt">tEXt</a>, <a class="chunk" href="#11iTXt">iTXt</a> and <a class="chunk" href="#11zTXt">zTXt</a>, contain data that can be displayed in the form of comments, etc. Some operating systems or terminals might allow the display of textual data with embedded control characters to perform operations such as re-mapping of keys, creation of files, etc. For this reason, the specification recommends that the text chunks be filtered for control characters before direct display.</p> <p>The PNG format is specifically designed to facilitate early detection of file transmission errors, and makes use of cyclical redundancy checks to ensure the integrity of the data contained in its chunks.</p> <p>If one creates an <abbr title="Animated PNG">APNG</abbr> file with unrelated static image and animated image chunks, somebody using a tool not supporting the <abbr title="Animated PNG">APNG</abbr> format would only see the static image and be unaware of the additional content. This could be used e.g. to bypass moderation.</p> </dd> <dt>Interoperability considerations:</dt> <dd>None</dd> <dt>Published specification:</dt> <dd> <a href="https://www.w3.org/TR/png/">Portable Network Graphics (PNG) Specification</a>, <a href="https://www.w3.org/TR/png/">https://www.w3.org/TR/png/</a> </dd> <dt>Applications which use this media:</dt> <dd>Animated PNG (<abbr title="Animated PNG">APNG</abbr>) is widely implemented in all Web browsers, and is increasingly available in image viewers, and animation and image creation tools</dd> <dt>Fragment identifier considerations:</dt> <dd>N/A</dd> <dt>Restrictions on usage:</dt> <dd>N/A</dd> <dt>Provisional registration? (standards tree only):</dt> <dd>No</dd> <dt>Additional information:</dt> <dd> <dl> <dt>Deprecated alias names for this type:</dt> <dd>image/vnd.mozilla.apng</dd> <dt>Magic number(s):</dt> <dd>89 50 4E 47 0D 0A 1A 0A</dd> <dt>File extension(s):</dt> <dd>.apng</dd> <dt>Object Identifiers:</dt> <dd>N/A</dd> </dl> </dd> <dt>General Comments:</dt> <dd> <p>image/apng has been in widespread, unregistered use since 2015. Animated PNG was not part of the official PNG specification until 2022. This registration, plus the PNG specification (3rd Edition) brings official documentation into alignment with already widely-deployed reality.</p> </dd> <dt>Person to contact for further information:</dt> <dd> <dl> <dt>Name:</dt> <dd>PNG Working Group</dd> <dt>Email:</dt> <dd> <a href="mailto:public-png@w3.org">public-png@w3.org</a> </dd> </dl> </dd> <dt>Intended usage:</dt> <dd>Common</dd> <dt>Author/Change controller:</dt> <dd><abbr title="World Wide Web Consortium">W3C</abbr></dd> </dl> </section> </section> <section class="appendix informative" id="B-NewChunksAppendix"><div class="header-wrapper"><h2 class="Annex" id="newchunks"><bdi class="secno">B. </bdi>Guidelines for private chunk types</h2><a class="self-link" href="#newchunks" aria-label="Permalink for Appendix B."></a></div><p><em>This section is non-normative.</em></p> <p>The following specifies guidelines for the definition of private chunks:</p> <ol> <li>Do not define new chunks that redefine the meaning of existing chunks or change the interpretation of an existing standardized chunk, e.g., do not add a new chunk to say that RGB and alpha values actually mean CMYK.</li> <li>Minimize the use of private chunks to aid portability.</li> <li>Avoid defining chunks that depend on total datastream contents. If such chunks have to be defined, make them critical chunks.</li> <li>For textual information that is representable in Latin-1 avoid defining a new chunk type. Use a <a class="chunk" href="#11tEXt">tEXt</a> or <a class="chunk" href="#11zTXt">zTXt</a> chunk with a suitable keyword to identify the type of information. For textual information that is not representable in Latin-1 but which can be represented in UTF-8, use an <a class="chunk" href="#11iTXt">iTXt</a> chunk with a suitable keyword. </li> <li>Group mutually dependent ancillary information into a single chunk. This avoids the need to introduce chunk ordering relationships.</li> <li>Avoid defining private critical chunks.</li> </ol> </section> <section class="appendix informative" id="C-GammaAppendix"><div class="header-wrapper"><h2 class="Annex" id="gammachromaticity"><bdi class="secno">C. </bdi>Gamma and chromaticity</h2><a class="self-link" href="#gammachromaticity" aria-label="Permalink for Appendix C."></a></div><p><em>This section is non-normative.</em></p> <p>A <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-28">gamma value</a> is a numerical parameter used to describe approximations to certain non-linear <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-20">transfer functions</a> encountered in image capture and reproduction. The <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-29">gamma value</a> is the exponent in a power law function. For example the function:</p> <p><code>intensity = (voltage + constant)<sup>exponent</sup></code> </p> <p>which is used to model the non-linearity of <abbr title="Cathode Ray Tube">CRT</abbr> displays. It is often assumed, as in this International Standard, that the constant is zero.</p> <p>For the purposes of this specification, it is convenient to consider five places in a general image pipeline at which non-linear <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-21">transfer functions</a> may occur and which may be modelled by power laws. The characteristic exponent associated with each is given a specific name.</p> <table id="gamma-pipeline" class="simple numbered"> <tbody><tr> <td><var>input_exponent</var> </td> <td>the exponent of the image sensor.</td> </tr> <tr> <td><var>encoding_exponent</var> </td> <td> the exponent of any <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-22">transfer function</a> performed by the process or device writing the datastream. </td> </tr> <tr> <td><var>decoding_exponent</var> </td> <td> the exponent of any <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-23">transfer function</a> performed by the software reading the <a href="#dfn-image-data" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-image-data-37">image data</a>stream. </td> </tr> <tr> <td><var>LUT_exponent</var> </td> <td> the exponent of the <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-24">transfer function</a> applied between the <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-13">frame buffer</a> and the display device (typically this is applied by a Look Up Table). </td> </tr> <tr> <td><var>output_exponent</var> </td> <td> the exponent of the display device. For a <abbr title="Cathode Ray Tube">CRT</abbr>, this is typically a value close to 2.2. </td> </tr> </tbody></table> <p>It is convenient to define some additional entities that describe some composite <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-25">transfer functions</a>, or combinations of stages.</p> <table id="gamma-composite" class="simple numbered"> <tbody><tr> <td><var>display_exponent</var> </td> <td> exponent of the <a href="#dfn-transfer-function" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-transfer-function-26">transfer function</a> applied between the <a href="#dfn-frame-buffer" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-frame-buffer-14">frame buffer</a> and the display surface of the display device.<br> <code>display_exponent = LUT_exponent * output_exponent</code> </td> </tr> <tr> <td><var>gamma</var> </td> <td>exponent of the function mapping display output intensity to samples in the PNG datastream.<br> <code>gamma = 1.0 / (decoding_exponent * display_exponent)</code></td> </tr> <tr> <td><var>end_to_end_exponent</var> </td> <td>the exponent of the function mapping image sensor input intensity to display output intensity. This is generally a value in the range 1.0 to 1.5.</td> </tr> </tbody></table> <p>The PNG <a class="chunk" href="#11gAMA">gAMA</a> chunk is used to record the <a href="#dfn-gamma-value" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-gamma-value-30">gamma value</a>. This information may be used by decoders together with additional information about the display environment in order to achieve, or approximate, the desired display output.</p> <p>Additional information about this subject may be found [<cite><a class="bibref" data-link-type="biblio" href="#bib-gamma-faq" title="Gamma FAQ">GAMMA-FAQ</a></cite>].</p> <p>Additional information on the impact of color space on image encoding may be found in [<cite><a class="bibref" data-link-type="biblio" href="#bib-kasson" title="An Analysis of Selected Computer Interchange Color Spaces">Kasson</a></cite>] and [<cite><a class="bibref" data-link-type="biblio" href="#bib-hill" title="Comparative analysis of the quantization of color spaces on the basis of the CIELAB color-difference formula">Hill</a></cite>].</p> <p>Background information about <a href="#dfn-chromaticity" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-chromaticity-5">chromaticity</a> and color spaces may be found in [<cite><a class="bibref" data-link-type="biblio" href="#bib-luminance-chromaticity" title="Luminance and Chromaticity">Luminance-Chromaticity</a></cite>] and [<cite><a class="bibref" data-link-type="biblio" href="#bib-color-faq" title="Color FAQ">COLOR-FAQ</a></cite>].</p> </section> <section class="appendix" id="D-CRCAppendix"><div class="header-wrapper"><h2 class="Annex" id="samplecrc"><bdi class="secno">D. </bdi>Sample <abbr title="Cyclic Redundancy Code">CRC</abbr> implementation</h2><a class="self-link" href="#samplecrc" aria-label="Permalink for Appendix D."></a></div> <p>The following sample code — which is informative — represents a practical implementation of the <abbr title="Cyclic Redundancy Code">CRC</abbr> (Cyclic Redundancy Check) employed in PNG chunks. (See also ISO 3309 [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso-3309" title="ISO/IEC 3309:1993, Information Technology — Telecommunications and information exchange between systems — High-level data link control (HDLC) procedures — Frame structure.">ISO-3309</a></cite>] or ITU-T V.42 [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-t-v.42" title="ITU-T V.42, SERIES V: DATA COMMUNICATION OVER THE TELEPHONE NETWORK. Error-correcting procedures for DCEs using asynchronous-to-synchronous conversion">ITU-T-V.42</a></cite>] for a formal specification.)</p> <p>The sample code is in the ISO C [<cite><a class="bibref" data-link-type="biblio" href="#bib-iso_9899" title="ISO/IEC 9899:2018 Information technology — Programming languages — C">ISO_9899</a></cite>] programming language. The hints in <a href="#D-tabled1" class="table-ref" title="Hints for reading ISO C code">Table <bdi class="">31</bdi></a> may help non-C users to read the code more easily.</p> <table id="D-tabled1" class="numbered simple"> <caption><a class="self-link" href="#D-tabled1">Table <bdi class="tableno">31</bdi></a> <span class="table-title"> Hints for reading ISO C code </span></caption> <tbody><tr> <th>Operator</th> <th>Description</th> </tr> <tr> <td><code>&</code> </td> <td>Bitwise AND operator.</td> </tr> <tr> <td><code>^</code> </td> <td>Bitwise exclusive-OR operator.</td> </tr> <tr> <td><code>>></code> </td> <td>Bitwise right shift operator. When applied to an unsigned quantity, as here, right shift inserts zeroes at the left.</td> </tr> <tr> <td><code>!</code> </td> <td>Logical NOT operator.</td> </tr> <tr> <td><code>++</code> </td> <td>"<code>n++</code>" increments the variable <var>n</var>. In "for" loops, it is applied after the variable is tested.</td> </tr> <tr> <td><code>0xNNN</code> </td> <td><code>0x</code> introduces a hexadecimal (base 16) constant. Suffix <code>L</code> indicates a long value (at least 32 bits).</td> </tr> </tbody></table> <hr> <pre aria-busy="false"><code class="hljs javascript"><span class="hljs-comment">/* Table of CRCs of all 8-bit messages. */</span> unsigned long crc_table[<span class="hljs-number">256</span>]; <span class="hljs-comment">/* Flag: has the table been computed? Initially false. */</span> int crc_table_computed = <span class="hljs-number">0</span>; <span class="hljs-comment">/* Make the table for a fast CRC. */</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">make_crc_table</span>(<span class="hljs-params"><span class="hljs-keyword">void</span></span>) { unsigned long c; int n, k; <span class="hljs-keyword">for</span> (n = <span class="hljs-number">0</span>; n < <span class="hljs-number">256</span>; n++) { c = (unsigned long) n; <span class="hljs-keyword">for</span> (k = <span class="hljs-number">0</span>; k < <span class="hljs-number">8</span>; k++) { <span class="hljs-keyword">if</span> (c & <span class="hljs-number">1</span>) c = 0xedb88320L ^ (c >> <span class="hljs-number">1</span>); <span class="hljs-keyword">else</span> c = c >> <span class="hljs-number">1</span>; } crc_table[n] = c; } crc_table_computed = <span class="hljs-number">1</span>; }</code></pre> <pre aria-busy="false"><code class="hljs javascript"><span class="hljs-comment">/* Update a running CRC with the bytes buf[0..len-1]--the CRC should be initialized to all 1's, and the transmitted value is the 1's complement of the final running CRC (see the crc() routine below). */</span> unsigned long <span class="hljs-title function_">update_crc</span>(<span class="hljs-params">unsigned long crc, unsigned char *buf, int len</span>) { unsigned long c = crc; int n; <span class="hljs-keyword">if</span> (!crc_table_computed) <span class="hljs-title function_">make_crc_table</span>(); <span class="hljs-keyword">for</span> (n = <span class="hljs-number">0</span>; n < len; n++) { c = crc_table[(c ^ buf[n]) & <span class="hljs-number">0xff</span>] ^ (c >> <span class="hljs-number">8</span>); } <span class="hljs-keyword">return</span> c; } <span class="hljs-comment">/* Return the CRC of the bytes buf[0..len-1]. */</span> unsigned long <span class="hljs-title function_">crc</span>(<span class="hljs-params">unsigned char *buf, int len</span>) { <span class="hljs-keyword">return</span> <span class="hljs-title function_">update_crc</span>(0xffffffffL, buf, len) ^ 0xffffffffL; }</code></pre> </section> <section class="appendix informative" id="E-Resources"><div class="header-wrapper"><h2 class="Annex" id="onlineresources"><bdi class="secno">E. </bdi>Online resources</h2><a class="self-link" href="#onlineresources" aria-label="Permalink for Appendix E."></a></div><p><em>This section is non-normative.</em></p> <section class="introductory" id="E-Intro"><div class="header-wrapper"><h3 id="introduction-10">Introduction</h3><a class="self-link" href="#E-Intro" aria-label="Permalink for this Appendix"></a></div> <p>This annex gives the locations of some Internet resources for PNG software developers. By the nature of the Internet, the list is incomplete and subject to change.</p> </section> <section id="E-icc-profile-specs"><div class="header-wrapper"><h3 id="e-1-icc-profile-specifications"><bdi class="secno">E.1 </bdi>ICC profile specifications</h3><a class="self-link" href="#E-icc-profile-specs" aria-label="Permalink for Appendix E.1"></a></div> <p>ICC profile specifications are available at: <a href="https://www.color.org/"><code>https://www.color.org/</code></a></p> </section> <section id="E-PNG-home-page"><div class="header-wrapper"><h3 id="e-2-png-web-site"><bdi class="secno">E.2 </bdi>PNG web site</h3><a class="self-link" href="#E-PNG-home-page" aria-label="Permalink for Appendix E.2"></a></div> <p>There is a World Wide Web site for PNG at <a href="http://www.libpng.org/pub/png/"><code>http://www.libpng.org/pub/png/</code></a>. This page is a central location for current information about PNG and PNG-related tools.</p> <p>Additional documentation and portable C code for <a href="#dfn-deflate" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-deflate-18">deflate</a>, and an optimized implementation of the <abbr title="Cyclic Redundancy Code">CRC</abbr> algorithm are available from the zlib web site, <a href="https://www.zlib.net/"><code>https://www.zlib.net/</code></a>.</p> </section> <section id="E-Sample-implementation"><div class="header-wrapper"><h3 id="e-3-sample-implementation-and-test-images"><bdi class="secno">E.3 </bdi>Sample implementation and test images</h3><a class="self-link" href="#E-Sample-implementation" aria-label="Permalink for Appendix E.3"></a></div> <p>A sample implementation in portable C, <strong>libpng</strong>, is available at <a href="http://www.libpng.org/pub/png/libpng.html"><code>http://www.libpng.org/pub/png/libpng.html</code></a>. Sample viewer and encoder applications of libpng are available at <a href="http://www.libpng.org/pub/png/book/sources.html"><code>http://www.libpng.org/pub/png/book/sources.html</code></a> and are described in detail in <i>PNG: The Definitive Guide</i> [<cite><a class="bibref" data-link-type="biblio" href="#bib-roelofs" title="PNG: The Definitive Guide">ROELOFS</a></cite>]. Test images can also be accessed from the PNG web site.</p> </section> </section> <section id="F-ChangeList" class="appendix informative"><div class="header-wrapper"><h2 class="Annex" id="f-changes"><bdi class="secno">F. </bdi>Changes</h2><a class="self-link" href="#F-ChangeList" aria-label="Permalink for Appendix F."></a></div><p><em>This section is non-normative.</em></p> <section id="changes-since-the-candidate-recommendation-draft-of-21-january-2025-third-edition"><div class="header-wrapper"><h3 id="changes-20250121/"><bdi class="secno">F.1 </bdi>Changes since the <a href="https://www.w3.org/TR/2025/CRD-png-3-20250121/">Candidate Recommendation Draft of 21 January 2025 (Third Edition)</a></h3><a class="self-link" href="#changes-20250121/" aria-label="Permalink for Appendix F.1"></a></div> <ul> <li>Credited original authors of the <span class="chunk">eXIf</span> chunk</li> <li>Removed pointless constraint that unsigned integers cannot be negative (!)</li> <li>Moved "Collection" keyword from extensions document to main specification</li> <li>Copied original security note regarding EXIF, from Extensions document</li> <li>Updated reference to latest version of ITU H.273</li> </ul> </section><section id="changes-since-the-candidate-recommendation-draft-of-18-july-2024-third-edition"><div class="header-wrapper"><h3 id="changes-20240718"><bdi class="secno">F.2 </bdi>Changes since the <a href="https://www.w3.org/TR/2024/CRD-png-3-20240718/">Candidate Recommendation Draft of 18 July 2024 (Third Edition)</a></h3><a class="self-link" href="#changes-20240718" aria-label="Permalink for Appendix F.2"></a></div> <ul> <li>Renamed <span class="chunk">mDCv</span> to <span class="chunk">mDCV</span></li> <li>Renamed <span class="chunk">cLLi</span> to <span class="chunk">cLLI</span></li> <li>Consistently require that <span class="chunk">acTL</span> only comes before <span class="chunk">IDAT</span>, not <span class="chunk">PLTE</span></li> </ul> </section><section id="changes-since-the-candidate-recommendation-snapshot-of-21-september-2023-third-edition"><div class="header-wrapper"><h3 id="changes-20230921"><bdi class="secno">F.3 </bdi>Changes since the <a href="https://www.w3.org/TR/2023/CR-png-3-20230921/">Candidate Recommendation Snapshot of 21 September 2023 (Third Edition)</a></h3><a class="self-link" href="#changes-20230921" aria-label="Permalink for Appendix F.3"></a></div> <ul> <li>Clarified that bit depth and color type fields can take private values</li> <li>Listed both decimal and hexadecimal values in MaxCLL and MaxFALL examples</li> <li>Corrected terminology in mDCV section</li> <li>Corrected "PNG image" in cHRM section</li> <li>Consolidated color chunk precedence information</li> <li>Added order of precedence for color space chunks</li> <li>Clarified color chunk priorities description</li> <li>Mark SMPTE RP 2077 as informative, since it is not freely available</li> <li>Added color chunk priority table</li> <li>Clarified alpha channels are always full-range</li> <li>Added <abbr title="Electro-Optical Transfer Function">EOTF</abbr> and <abbr title="Opto-Electrical Transfer Function">OETF</abbr> definitions</li> <li>Added recommendation for handling negative values resulting from narrow-range images using an extended range transfer function</li> <li>Clarified "video" from "video full range flag) is used to match H.273 wording but still applies to still images</li> <li>Added link to IANA subtag registry</li> <li>Fixed links to alhpa compaction and alpha separation sections</li> <li>Fixed broken tRNS link</li> <li>Added Display P3 cICP example</li> <li>Changed "perceived" wording to "measured", as luminance and chromaticity don't define a perceived color</li> <li>Clarified which metadata forms part of HDR10</li> <li>Updated link to latest version of ITU-R BT.2390</li> <li>Noted that currently there is no published standard to adapt an SDR image from default viewing conditions (display luminance and ambient illumination) to those given in <span class="chunk">mDCV</span></li> <li>Noted that the adaptation of BT.2100 HLG images to differing viewing conditions, given in BT.2390, may also be used with SDR images.</li> <li>Noted that tone mapping, to adjust the luminance levels given in <span class="chunk">cLLI</span> to those of a target display to prevent clipping, is particularly important for formats such as BT.2100 PQ which use absolute luminance.</li> <li>Noted that use of full-range BT.709 values, while common, is not part of the BT.709 standard</li> <li>Added mention of protected code values for Serial Digital Interface (baseband video) in description of narrow-range and full-range video</li> <li>Added reference to ITU-R-BT.2390</li> <li>Changed description of <span class="chunk">mDCV</span> to focus on BT.2100 PQ, as use with other formats is currently rare</li> <li>Clarified matching requirements for 16-bit <span class="chunk">tRNS</span> matching</li> <li>Used more precise "primary chromaticities" rather than just "primaries"</li> <li>Added requirement that <span class="chunk">mDCV</span> requires an accompanying <span class="chunk">cICP</span> to fit with expectations of existing HDR10 workflows</li> <li>Better explanation of <code>Video Full Range Flag</code></li> <li>Clarified ordering and encoding of sequence numbers, clarified <span class="chunk">fdAT</span> concatenation is in order of sequence number</li> <li>Added missing mentions of <span class="chunk">cICP</span> in descriptions of related chunks</li> <li>Fully specified the ordering and byte-order of fields in <span class="chunk">mDCV</span></li> <li>Added missing definition of PNG two-byte unsigned integer</li> <li>Used Display P3, rather than sRGB, in SDR <span class="chunk">mDCV</span> examples</li> <li>Added Chris Needham as co-author</li> <li>Updated examples for <span class="chunk">mDCV</span>, added reference to SMPTE-ST-2086.</li> <li>Added reference to Display P3</li> <li>Explicitly mentioned that the concatenated data from <span class="chunk">IDAT</span> and <span class="chunk">fdAT</span> may include chunks with zero-length data</li> <li>Assorted non-substantive improvements to markup, styling, internal cross-linking, correction of typos, punctuation, grammar, consistent use of US English, etc</li> </ul> </section><section id="changes-since-the-working-draft-of-20-july-2023-third-edition"><div class="header-wrapper"><h3 id="changes-20230720"><bdi class="secno">F.4 </bdi>Changes since the <a href="https://www.w3.org/TR/2023/WD-png-3-20230720/"> Working Draft of 20 July 2023 (Third Edition)</a></h3><a class="self-link" href="#changes-20230720" aria-label="Permalink for Appendix F.4"></a></div> <ul> <li>Clarified descriptions of <span class="chunk">mDCV</span> and <span class="chunk">cLLi</span></li> <li>Added note to Security Considerations about potentially malicious data after <span class="chunk">IEND</span>.</li> <li>Clarified that <a href="#cLLI-chunk" class="chunk">cLLI</a> is for HDR content</li> <li>Added an informative reference to Smith & Zink "On the Calculation and Usage of HDR Static Content Metadata"</li> <li>Added an informative reference to CTA-861.3-A for static HDR metadata</li> <li>Fixed broken reference to ITU-R BT.2100 </li> <li>Updated reference to SMPTE-ST-2067-21</li> <li>Added guidance on calculating MaxCLL and MaxFALL values</li> <li>Added example (live streaming) where <a href="#cLLI-chunk" class="chunk">cLLI</a> could not be pre-calculated</li> <li>Added definitions for stop, SDR, HDR, HLG and PQ</li> <li>Clarified definition of narrow-range</li> <li>Updated ITU-T H Suppl. 19 reference to latest version</li> <li>Added Simon Thompson as an author</li> <li>Mandated current browser handling of out-of-range palette indices</li> <li>Updated "Additional Information" table to add <a href="#mDCV-chunk" class="chunk">mDCV</a> and <a href="#cLLI-chunk" class="chunk">cLLI</a>.</li> </ul> </section><section id="changes-since-the-first-public-working-draft-of-25-october-2022-third-edition"><div class="header-wrapper"><h3 id="changes-20221025"><bdi class="secno">F.5 </bdi>Changes since the <a href="https://www.w3.org/TR/2022/WD-png-3-20221025/"> First Public Working Draft of 25 October 2022 (Third Edition)</a></h3><a class="self-link" href="#changes-20221025" aria-label="Permalink for Appendix F.5"></a></div> <ul> <li>Explained preferable handling of trailing bytes in the final <a href="#11IDAT" class="chunk">IDAT</a> chunk for encoders and decoders.</li> <li>Linked to open issue on tone-mapping <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-8">HDR</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] images in the presence of <a href="#mDCV-chunk" class="chunk">mDCV</a>.</li> <li>Follow the Encoding Standard on UTF-8 encode and decode.</li> <li>Added definition of a frame.</li> <li>Required the Matrix Coefficients in <a href="#cICP-chunk" class="chunk">cICP</a> to be zero (RGB data).</li> <li>Added known Privacy issue with recoverable data that only appears to have been redacted.</li> <li>Improved advice on choosing filters.</li> <li>Added links to color image type definitions.</li> <li>Clarified that MaxFALL uses the values of the frame with highest mean luminance.</li> <li>Clarified luminance units.</li> <li>Prefer RFC 3339 format for Creation Time.</li> <li>Improved the definition of <a href="#mDCV-chunk" class="chunk">mDCV</a>, with better descriptions, default values, and reference to SMPTE standards.</li> <li>Refactored the terms and definitions, for clarity.</li> <li>Improved definitions of source, reference, and PNG images.</li> <li>Moved concepts from the terms and definitions section to the main prose.</li> <li>Corrected error in <a href="#eXIf" class="chunk">eXIf</a> chunk, which conflicted with the <a href="#5ChunkOrdering">chunk ordering</a> section.</li> <li>Simplified <a href="#1Scope">Scope</a> section to remove redundant detail described elsewhere.</li> <li>Redrew chunk-ordering lattice diagrams to be clearer and more consistent.</li> <li>Added a new chunk, <a href="#cLLI-chunk" class="chunk">cLLI</a>, to describe the Maximum Single-Pixel and Frame-Average Luminance Levels for both static and animated <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-9">HDR</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] PNG images. </li> <li>Updated external links to latest versions, preferring https over http.</li> <li>Specified interoperable handling of extra sample bits, beyond the specified bit depth, in <a href="#11tRNS" class="chunk">tRNS</a> and <a href="#11bKGD" class="chunk">bKGD</a> chunks. </li> <li>Added a new chunk, <a href="#mDCV-chunk" class="chunk">mDCV</a> to describe the color volume of the mastering display used to grade <a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-10">HDR</a> [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] content.</li> <li>Used correct Unicode character names.</li> <li>Changed chunk type codes to use hexadecimal, rather than decimal.</li> <li>Described textual chunk processing more clearly.</li> <li>Recommended <a href="#11iTXt" class="chunk">iTXt</a> for new content.</li> <li>Clarifications on the language tag field of the <a href="#11iTXt" class="chunk">iTXt</a> chunk, corrected examples to conform to BCP47.</li> <li>Updated image/apng registration appendix. <abbr title="Animated PNG">APNG</abbr> MIME type registered with IANA.</li> <li>Converted ACII-art figures to more accessible diagrams.</li> </ul> </section><section id="changes-since-the-w3c-recommendation-of-10-november-2003-png-second-edition"><div class="header-wrapper"><h3 id="changes-20031110"><bdi class="secno">F.6 </bdi>Changes since the <a href="https://www.w3.org/TR/2003/REC-PNG-20031110/"><abbr title="World Wide Web Consortium">W3C</abbr> Recommendation of 10 November 2003</a> (PNG Second Edition)</h3><a class="self-link" href="#changes-20031110" aria-label="Permalink for Appendix F.6"></a></div> <ul> <li> <p>The three previously defined, but unofficial, chunks for Animated PNG (<abbr title="Animated PNG">APNG</abbr>) have been added:</p> <ul> <li><a href="#acTL-chunk" class="chunk">acTL</a> Animation Control Chunk</li> <li><a href="#fcTL-chunk" class="chunk">fcTL</a> Frame Control Chunk</li> <li><a href="#fdAT-chunk" class="chunk">fdAT</a> Frame Data Chunk</li> </ul> <p>This brings the PNG specification into alignment with widely deployed industry practice.</p> </li> <li> <p>Added the <a class="chunk" href="#cICP-chunk">cICP</a> chunk, Coding-independent code points for video signal type identification, to contain image format metadata defined in [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-t-h.273" title="ITU-T H.273, SERIES H: AUDIOVISUAL AND MULTIMEDIA SYSTEMS Infrastructure of audiovisual services – Coding of moving video. Coding-independent code points for video signal type identification">ITU-T-H.273</a></cite>] which enables PNG to contain [<cite><a class="bibref" data-link-type="biblio" href="#bib-itu-r-bt.2100" title="ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange">ITU-R-BT.2100</a></cite>] High Dynamic Range (<a href="#dfn-hdr" class="internalDFN" data-link-type="dfn" id="ref-for-dfn-hdr-11">HDR</a>) and Wide Color Gamut (WCG) images.</p> </li> <li> <p>For chunks which define the image color space, the order of precedence is clearly defined, if more than one is present.</p> </li> <li> <p>The previously defined <a class="chunk" href="#eXIf">eXIf</a> chunk has been moved from the PNG-Extensions document [<cite><a class="bibref" data-link-type="biblio" href="#bib-png-extensions" title="Extensions to the PNG Third Edition Specification, Version 1.6.0">PNG-EXTENSIONS</a></cite>] into the main body of this specification, to reflect its increasing use.</p> </li> <li> <p>To help with tonemapping HDR content, added the <a class="chunk" href="#mDCV-chunk">mDCV</a> chunk, which contains metadata about the display used in mastering, and <a href="#cLLI-chunk" class="chunk">cLLI</a>, which contains metadata about peak and average light levels. This enabled more accurate color matching on heterogeneous platforms</p> </li> <li> <p>Clarified that the <a href="#11iCCP" class="chunk">iCCP</a> chunk, which contains an ICC profile, can contain profiles conforming to any version of the ICC.1 specification. PNG Second Edition only referenced the then-current v2 of ICC.1, although it has since become industry practice to also used higher versions.</p> </li> <li> <p>Clarified handling of out-of-range indexes, for indexed-color PNG</p> </li> <li> <p>Clarified error recovery for unknown and invalid ancillary chunks</p> </li> <li> <p>Incorporation of all <a href="https://www.w3.org/2003/11/REC-PNG-20031110-errata">PNG Second Edition Errata</a>. Notably, clarified that PNG images with unknown gamma value, when embedded in formats such as HTML or SVG, must be treated as <a href="https://drafts.csswg.org/css-color-4/#untagged">untagged images</a></p> </li> <li> <p>Various editorial clarifications in response to community feedback</p> </li> <li> <p>References updated to latest versions</p> </li> <li> <p>Markup corrections and link fixes</p> </li> <li> <p>Document source reformatted to use ReSpec</p> </li> </ul> </section><section id="changes-between-first-and-second-editions"><div class="header-wrapper"><h3 id="f-7-changes-between-first-and-second-editions"><bdi class="secno">F.7 </bdi>Changes between First and Second Editions</h3><a class="self-link" href="#changes-between-first-and-second-editions" aria-label="Permalink for Appendix F.7"></a></div> <p>For the list of changes between <abbr title="World Wide Web Consortium">W3C</abbr> Recommendation <a href="https://www.w3.org/TR/REC-png-961001">PNG Specification Version 1.0</a> and <a href="https://www.w3.org/TR/2003/REC-PNG-20031110/">PNG Second Edition</a>, see <a href="https://www.w3.org/TR/2003/REC-PNG-20031110/#F-ChangeList">PNG Second Edition changelist</a></p> </section></section> <script type="application/javascript" src="https://www.w3.org/scripts/TR/fixup.js"></script> <section id="references" class="appendix"><div class="header-wrapper"><h2 id="g-references"><bdi class="secno">G. </bdi>References</h2><a class="self-link" href="#references" aria-label="Permalink for Appendix G."></a></div><section id="normative-references"><div class="header-wrapper"><h3 id="g-1-normative-references"><bdi class="secno">G.1 </bdi>Normative references</h3><a class="self-link" href="#normative-references" aria-label="Permalink for Appendix G.1"></a></div> <dl class="bibliography"><dt id="bib-bcp47">[BCP47]</dt><dd> <a href="https://www.rfc-editor.org/rfc/rfc5646"><cite>Tags for Identifying Languages</cite></a>. A. Phillips, Ed.; M. Davis, Ed. IETF. September 2009. Best Current Practice. URL: <a href="https://www.rfc-editor.org/rfc/rfc5646">https://www.rfc-editor.org/rfc/rfc5646</a> </dd><dt id="bib-cipa-dc-008">[CIPA-DC-008]</dt><dd> <a href="https://www.cipa.jp/std/documents/download_e.html?DC-008-Translation-2019-E"><cite>Exchangeable image file format for digital still cameras: Exif Version 2.32</cite></a>. Camera & Imaging Products Association. 2019-05-17. URL: <a href="https://www.cipa.jp/std/documents/download_e.html?DC-008-Translation-2019-E">https://www.cipa.jp/std/documents/download_e.html?DC-008-Translation-2019-E</a> </dd><dt id="bib-colorimetry">[COLORIMETRY]</dt><dd> <a href="http://www.cie.co.at/publications/colorimetry-4th-edition"><cite>Colorimetry, Fourth Edition. CIE 015:2018</cite></a>. CIE. 2018. URL: <a href="http://www.cie.co.at/publications/colorimetry-4th-edition">http://www.cie.co.at/publications/colorimetry-4th-edition</a> </dd><dt id="bib-display-p3">[Display-P3]</dt><dd> <a href="https://www.color.org/chardata/rgb/DisplayP3.xalter"><cite>Display P3</cite></a>. Apple, Inc. ICC. 2022-02. URL: <a href="https://www.color.org/chardata/rgb/DisplayP3.xalter">https://www.color.org/chardata/rgb/DisplayP3.xalter</a> </dd><dt id="bib-encoding">[ENCODING]</dt><dd> <a href="https://encoding.spec.whatwg.org/"><cite>Encoding Standard</cite></a>. Anne van Kesteren. WHATWG. Living Standard. URL: <a href="https://encoding.spec.whatwg.org/">https://encoding.spec.whatwg.org/</a> </dd><dt id="bib-icc">[ICC]</dt><dd> <a href="http://www.color.org/specification/ICC.1-2022-05.pdf"><cite>ICC.1:2022 (Profile version 4.4.0.0)</cite></a>. International Color Consortium. May 2022. URL: <a href="http://www.color.org/specification/ICC.1-2022-05.pdf">http://www.color.org/specification/ICC.1-2022-05.pdf</a> </dd><dt id="bib-icc-2">[ICC-2]</dt><dd> <a href="https://www.color.org/specification/ICC.2-2019.pdf"><cite>Specification ICC.2:2019 (Profile version 5.0.0 - iccMAX)</cite></a>. International Color Consortium. 2019. URL: <a href="https://www.color.org/specification/ICC.2-2019.pdf">https://www.color.org/specification/ICC.2-2019.pdf</a> </dd><dt id="bib-iso_15076-1">[ISO_15076-1]</dt><dd> <a href="https://www.iso.org/standard/54754.html"><cite>ISO 15076-1:2010 Image technology colour management — Architecture, profile format and data structure — Part 1: Based on ICC.1:2010</cite></a>. ISO. 2010-12. URL: <a href="https://www.iso.org/standard/54754.html">https://www.iso.org/standard/54754.html</a> </dd><dt id="bib-iso_8859-1">[ISO_8859-1]</dt><dd> <cite>ISO/IEC 8859-1:1998, Information technology — 8-bit single-byte coded graphic character sets — Part 1: Latin alphabet No. 1.</cite>. ISO. 1998. </dd><dt id="bib-iso_9899">[ISO_9899]</dt><dd> <a href="https://www.iso.org/standard/74528.html"><cite>ISO/IEC 9899:2018 Information technology — Programming languages — C</cite></a>. ISO. 2018-6. URL: <a href="https://www.iso.org/standard/74528.html">https://www.iso.org/standard/74528.html</a> </dd><dt id="bib-iso-3309">[ISO-3309]</dt><dd> <cite>ISO/IEC 3309:1993, Information Technology — Telecommunications and information exchange between systems — High-level data link control (HDLC) procedures — Frame structure.</cite>. ISO. 1993. </dd><dt id="bib-iso646">[ISO646]</dt><dd> <a href="https://www.iso.org/standard/4777.html"><cite>Information technology — ISO 7-bit coded character set for information interchange</cite></a>. International Organization for Standardization (ISO). December 1991. Published. URL: <a href="https://www.iso.org/standard/4777.html">https://www.iso.org/standard/4777.html</a> </dd><dt id="bib-itu-r-bt.2100">[ITU-R-BT.2100]</dt><dd> <a href="https://www.itu.int/rec/R-REC-BT.2100"><cite>ITU-R BT.2100, SERIES BT: BROADCASTING SERVICE (TELEVISION). Image parameter values for high dynamic range television for use in production and international programme exchange</cite></a>. ITU. 2018-07. URL: <a href="https://www.itu.int/rec/R-REC-BT.2100">https://www.itu.int/rec/R-REC-BT.2100</a> </dd><dt id="bib-itu-r-bt.709">[ITU-R-BT.709]</dt><dd> <a href="https://www.itu.int/rec/R-REC-BT.709"><cite>ITU-R BT.709, SERIES BT: BROADCASTING SERVICE (TELEVISION). Parameter values for the HDTV standards for production and international programme exchange</cite></a>. ITU. 2015-06. URL: <a href="https://www.itu.int/rec/R-REC-BT.709">https://www.itu.int/rec/R-REC-BT.709</a> </dd><dt id="bib-itu-t-h.273">[ITU-T-H.273]</dt><dd> <a href="https://www.itu.int/rec/T-REC-H.273"><cite>ITU-T H.273, SERIES H: AUDIOVISUAL AND MULTIMEDIA SYSTEMS Infrastructure of audiovisual services – Coding of moving video. Coding-independent code points for video signal type identification</cite></a>. ITU. 2024-07-14. URL: <a href="https://www.itu.int/rec/T-REC-H.273">https://www.itu.int/rec/T-REC-H.273</a> </dd><dt id="bib-itu-t-series-h-supplement-19">[ITU-T-Series-H-Supplement-19]</dt><dd> <a href="https://www.itu.int/ITU-T/recommendations/rec.aspx?rec=14652"><cite>Series H: Audio Visual and Multimedia Systems - Usage of video signal type code points</cite></a>. ITU. 2021-04. URL: <a href="https://www.itu.int/ITU-T/recommendations/rec.aspx?rec=14652">https://www.itu.int/ITU-T/recommendations/rec.aspx?rec=14652</a> </dd><dt id="bib-itu-t-v.42">[ITU-T-V.42]</dt><dd> <a href="https://www.itu.int/rec/T-REC-V.42-200203-I/en"><cite>ITU-T V.42, SERIES V: DATA COMMUNICATION OVER THE TELEPHONE NETWORK. Error-correcting procedures for DCEs using asynchronous-to-synchronous conversion</cite></a>. ITU. 2002-03-29. URL: <a href="https://www.itu.int/rec/T-REC-V.42-200203-I/en">https://www.itu.int/rec/T-REC-V.42-200203-I/en</a> </dd><dt id="bib-jpeg">[JPEG]</dt><dd> <a href="https://www.w3.org/Graphics/JPEG/jfif3.pdf"><cite>JPEG File Interchange Format</cite></a>. Eric Hamilton. C-Cube Microsystems. Milpitas, CA, USA. September 1992. URL: <a href="https://www.w3.org/Graphics/JPEG/jfif3.pdf">https://www.w3.org/Graphics/JPEG/jfif3.pdf</a> </dd><dt id="bib-paeth">[Paeth]</dt><dd> <a href="https://www.sciencedirect.com/science/article/pii/B9780080507545500293"><cite>Image File Compression Made Easy, in Graphics Gems II, pp. 93-100</cite></a>. Paeth, A.W. Academic Press. 1991. URL: <a href="https://www.sciencedirect.com/science/article/pii/B9780080507545500293">https://www.sciencedirect.com/science/article/pii/B9780080507545500293</a> </dd><dt id="bib-png-extensions">[PNG-EXTENSIONS]</dt><dd> <a href="https://w3c.github.io/png/extensions/Overview.html"><cite>Extensions to the PNG Third Edition Specification, Version 1.6.0</cite></a>. W3C. 2021. URL: <a href="https://w3c.github.io/png/extensions/Overview.html">https://w3c.github.io/png/extensions/Overview.html</a> </dd><dt id="bib-rfc1123">[rfc1123]</dt><dd> <a href="https://www.rfc-editor.org/rfc/rfc1123"><cite>Requirements for Internet Hosts - Application and Support</cite></a>. R. Braden, Ed. IETF. October 1989. Internet Standard. URL: <a href="https://www.rfc-editor.org/rfc/rfc1123">https://www.rfc-editor.org/rfc/rfc1123</a> </dd><dt id="bib-rfc1950">[rfc1950]</dt><dd> <a href="https://www.rfc-editor.org/rfc/rfc1950"><cite>ZLIB Compressed Data Format Specification version 3.3</cite></a>. P. Deutsch; J-L. Gailly. IETF. May 1996. Informational. URL: <a href="https://www.rfc-editor.org/rfc/rfc1950">https://www.rfc-editor.org/rfc/rfc1950</a> </dd><dt id="bib-rfc1951">[RFC1951]</dt><dd> <a href="https://www.rfc-editor.org/rfc/rfc1951"><cite>DEFLATE Compressed Data Format Specification version 1.3</cite></a>. P. Deutsch. IETF. May 1996. Informational. URL: <a href="https://www.rfc-editor.org/rfc/rfc1951">https://www.rfc-editor.org/rfc/rfc1951</a> </dd><dt id="bib-rfc1952">[RFC1952]</dt><dd> <a href="https://www.rfc-editor.org/rfc/rfc1952"><cite>GZIP file format specification version 4.3</cite></a>. P. Deutsch. IETF. May 1996. Informational. URL: <a href="https://www.rfc-editor.org/rfc/rfc1952">https://www.rfc-editor.org/rfc/rfc1952</a> </dd><dt id="bib-rfc2119">[RFC2119]</dt><dd> <a href="https://www.rfc-editor.org/rfc/rfc2119"><cite>Key words for use in RFCs to Indicate Requirement Levels</cite></a>. S. Bradner. IETF. March 1997. Best Current Practice. URL: <a href="https://www.rfc-editor.org/rfc/rfc2119">https://www.rfc-editor.org/rfc/rfc2119</a> </dd><dt id="bib-rfc3339">[rfc3339]</dt><dd> <a href="https://www.rfc-editor.org/rfc/rfc3339"><cite>Date and Time on the Internet: Timestamps</cite></a>. G. Klyne; C. Newman. IETF. July 2002. Proposed Standard. URL: <a href="https://www.rfc-editor.org/rfc/rfc3339">https://www.rfc-editor.org/rfc/rfc3339</a> </dd><dt id="bib-rfc3629">[rfc3629]</dt><dd> <a href="https://www.rfc-editor.org/rfc/rfc3629"><cite>UTF-8, a transformation format of ISO 10646</cite></a>. F. Yergeau. IETF. November 2003. Internet Standard. URL: <a href="https://www.rfc-editor.org/rfc/rfc3629">https://www.rfc-editor.org/rfc/rfc3629</a> </dd><dt id="bib-rfc8174">[RFC8174]</dt><dd> <a href="https://www.rfc-editor.org/rfc/rfc8174"><cite>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</cite></a>. B. Leiba. IETF. May 2017. Best Current Practice. URL: <a href="https://www.rfc-editor.org/rfc/rfc8174">https://www.rfc-editor.org/rfc/rfc8174</a> </dd><dt id="bib-smpte-170m">[SMPTE-170M]</dt><dd> <a href="https://standards.globalspec.com/std/892300/SMPTE%20ST%20170M"><cite>Television — Composite Analog Video Signal — NTSC for Studio Applications</cite></a>. Society of Motion Picture and Television Engineers. 2004-11-30. URL: <a href="https://standards.globalspec.com/std/892300/SMPTE%20ST%20170M">https://standards.globalspec.com/std/892300/SMPTE%20ST%20170M</a> </dd><dt id="bib-smpte-st-2086">[SMPTE-ST-2086]</dt><dd> <a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8353899"><cite>Mastering Display Color Volume Metadata Supporting High Luminance and Wide Color Gamut Images</cite></a>. Society of Motion Picture and Television Engineers. 27 April 2018. URL: <a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8353899">https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8353899</a> </dd><dt id="bib-srgb">[SRGB]</dt><dd> <a href="https://webstore.iec.ch/publication/6169"><cite>Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB</cite></a>. IEC. URL: <a href="https://webstore.iec.ch/publication/6169">https://webstore.iec.ch/publication/6169</a> </dd><dt id="bib-xmp">[XMP]</dt><dd> <a href="http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=57421"><cite>Extensible metadata platform (XMP) specification -- Part 1</cite></a>. Adobe Systems Incorporated. ISO/IEC. April 2019. URL: <a href="https://www.iso.org/standard/75163.html">https://www.iso.org/standard/75163.html</a> </dd><dt id="bib-ziv-lempel">[Ziv-Lempel]</dt><dd> <a href="https://ieeexplore.ieee.org/document/1055714"><cite>A Universal Algorithm for Sequential Data Compression, IEEE Transactions on Information Theory, vol. IT-23, no. 3, pp. 337 - 343</cite></a>. J. Ziv; A. Lempel. IEEE. 1977-05. URL: <a href="https://ieeexplore.ieee.org/document/1055714">https://ieeexplore.ieee.org/document/1055714</a> </dd></dl> </section><section id="informative-references"><div class="header-wrapper"><h3 id="g-2-informative-references"><bdi class="secno">G.2 </bdi>Informative references</h3><a class="self-link" href="#informative-references" aria-label="Permalink for Appendix G.2"></a></div> <dl class="bibliography"><dt id="bib-color-faq">[COLOR-FAQ]</dt><dd> <a href="https://poynton.ca/ColorFAQ.html"><cite>Color FAQ</cite></a>. Poynton, C.2009-10-19. URL: <a href="https://poynton.ca/ColorFAQ.html">https://poynton.ca/ColorFAQ.html</a> </dd><dt id="bib-cta-861.3-a">[CTA-861.3-A]</dt><dd> <a href="https://shop.cta.tech/products/hdr-static-metadata-extensions"><cite>HDR Static Metadata Extensions (CTA-861.3-A)</cite></a>. Consumer Technology Association. 2015-01. URL: <a href="https://shop.cta.tech/products/hdr-static-metadata-extensions">https://shop.cta.tech/products/hdr-static-metadata-extensions</a> </dd><dt id="bib-ebu-r-103">[EBU-R-103]</dt><dd> <a href="https://tech.ebu.ch/docs/r/r103.pdf"><cite>Video Signal Tolerance in Digital Television Systems</cite></a>. EBU. 2020-05. URL: <a href="https://tech.ebu.ch/docs/r/r103.pdf">https://tech.ebu.ch/docs/r/r103.pdf</a> </dd><dt id="bib-gamma-faq">[GAMMA-FAQ]</dt><dd> <a href="https://poynton.ca/GammaFAQ.html"><cite>Gamma FAQ</cite></a>. Poynton, C.1998-08-04. URL: <a href="https://poynton.ca/GammaFAQ.html">https://poynton.ca/GammaFAQ.html</a> </dd><dt id="bib-gif">[GIF]</dt><dd> <a href="https://www.w3.org/Graphics/GIF/spec-gif89a.txt"><cite>Graphics Interchange Format</cite></a>. CompuServe Incorporated. 31 July 1990. URL: <a href="https://www.w3.org/Graphics/GIF/spec-gif89a.txt">https://www.w3.org/Graphics/GIF/spec-gif89a.txt</a> </dd><dt id="bib-hdr-static-meta">[HDR-Static-Meta]</dt><dd> <a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9508136"><cite>On the Calculation and Usage of HDR Static Content Metadata</cite></a>. Smith, Michael D.; Zink, Michael. Society of Motion Picture and Television Engineers. 2021-08-05. URL: <a href="https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9508136">https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=9508136</a> </dd><dt id="bib-hdr10">[HDR10]</dt><dd> <a href="https://en.wikipedia.org/wiki/HDR10"><cite>HDR10 Media Profile</cite></a>. URL: <a href="https://en.wikipedia.org/wiki/HDR10">https://en.wikipedia.org/wiki/HDR10</a> </dd><dt id="bib-hill">[Hill]</dt><dd> <a href="https://dl.acm.org/doi/10.1145/248210.248212"><cite>Comparative analysis of the quantization of color spaces on the basis of the CIELAB color-difference formula</cite></a>. Hill, B.; Roger, Th.; Vorhagen, F.W.1997-04. URL: <a href="https://dl.acm.org/doi/10.1145/248210.248212">https://dl.acm.org/doi/10.1145/248210.248212</a> </dd><dt id="bib-itu-r-bt.2020">[ITU-R-BT.2020]</dt><dd> <a href="https://www.itu.int/rec/R-REC-BT.2020"><cite>Parameter values for ultra-high definition television systems for production and international programme exchange</cite></a>. ITU. URL: <a href="https://www.itu.int/rec/R-REC-BT.2020">https://www.itu.int/rec/R-REC-BT.2020</a> </dd><dt id="bib-itu-r-bt.2390">[ITU-R-BT.2390]</dt><dd> <a href="https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2390-11-2023-PDF-E.pdf"><cite>High dynamic range television for production and international programme exchange</cite></a>. ITU. URL: <a href="https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2390-11-2023-PDF-E.pdf">https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2390-11-2023-PDF-E.pdf</a> </dd><dt id="bib-kasson">[Kasson]</dt><dd> <a href="https://dl.acm.org/doi/abs/10.1145/146443.146479"><cite>An Analysis of Selected Computer Interchange Color Spaces</cite></a>. Kasson, J.; W. Plouffe. 1992. URL: <a href="https://dl.acm.org/doi/abs/10.1145/146443.146479">https://dl.acm.org/doi/abs/10.1145/146443.146479</a> </dd><dt id="bib-luminance-chromaticity">[Luminance-Chromaticity]</dt><dd> <a href="https://colorusage.arc.nasa.gov/lum_and_chrom.php"><cite>Luminance and Chromaticity</cite></a>. Color Usage Research Lab, NASA Ames Research Center. URL: <a href="https://colorusage.arc.nasa.gov/lum_and_chrom.php">https://colorusage.arc.nasa.gov/lum_and_chrom.php</a> </dd><dt id="bib-postscript">[PostScript]</dt><dd> <cite>PostScript Language Reference Manual</cite>. Adobe Systems Incorporated. Addison-Wesley. 1990. </dd><dt id="bib-roelofs">[ROELOFS]</dt><dd> <a href="http://www.libpng.org/pub/png/pngbook.html"><cite>PNG: The Definitive Guide</cite></a>. Roelofs, G. O'Reilly & Associates Inc. 1999-06-11. URL: <a href="http://www.libpng.org/pub/png/pngbook.html">http://www.libpng.org/pub/png/pngbook.html</a> </dd><dt id="bib-smpte-rp-177">[SMPTE-RP-177]</dt><dd> <a href="https://standards.globalspec.com/std/1284890/smpte-rp-177"><cite>Derivation of Basic Television Color Equations</cite></a>. Society of Motion Picture and Television Engineers. 1 November 1993. URL: <a href="https://standards.globalspec.com/std/1284890/smpte-rp-177">https://standards.globalspec.com/std/1284890/smpte-rp-177</a> </dd><dt id="bib-smpte-rp-2077">[SMPTE-RP-2077]</dt><dd> <a href="https://doi.org/10.5594/SMPTE.RP2077.2013"><cite>Full-Range Image Mapping</cite></a>. Society of Motion Picture and Television Engineers. 2013-01-01. URL: <a href="https://doi.org/10.5594/SMPTE.RP2077.2013">https://doi.org/10.5594/SMPTE.RP2077.2013</a> </dd><dt id="bib-smpte-st-2067-21">[SMPTE-ST-2067-21]</dt><dd> <a href="https://doi.org/10.5594/SMPTE.ST2067-21.2023"><cite>Interoperable Master Format — Application #2E</cite></a>. Society of Motion Picture and Television Engineers. 2023-02-20. URL: <a href="https://doi.org/10.5594/SMPTE.ST2067-21.2023">https://doi.org/10.5594/SMPTE.ST2067-21.2023</a> </dd><dt id="bib-tiff-6.0">[TIFF-6.0]</dt><dd> <a href="https://www.loc.gov/preservation/digital/formats/fdd/fdd000022.shtml"><cite>TIFF Revision 6.0</cite></a>. 3 June 1992. URL: <a href="https://www.loc.gov/preservation/digital/formats/fdd/fdd000022.shtml">https://www.loc.gov/preservation/digital/formats/fdd/fdd000022.shtml</a> </dd></dl> </section></section><p role="navigation" id="back-to-top"> <a href="#title"><abbr title="Back to Top">↑</abbr></a> </p><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-byte" aria-label="Links in this document to definition: byte"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-byte" aria-label="Permalink for definition: byte. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-byte-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> <a href="#ref-for-dfn-byte-2" title="Reference 2">(2)</a> <a href="#ref-for-dfn-byte-3" title="Reference 3">(3)</a> <a href="#ref-for-dfn-byte-4" title="Reference 4">(4)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-byte-order" aria-label="Links in this document to definition: byte order"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-byte-order" aria-label="Permalink for definition: byte order. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-byte-order-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-chromaticity" aria-label="Links in this document to definition: chromaticity"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-chromaticity" aria-label="Permalink for definition: chromaticity. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-chromaticity-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> <a href="#ref-for-dfn-chromaticity-2" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-chromaticity-3" title="§ 4.7 Additional information">§ 4.7 Additional information</a> </li><li> <a href="#ref-for-dfn-chromaticity-4" title="§ 11.3.4.4 sPLT Suggested palette">§ 11.3.4.4 sPLT Suggested palette</a> </li><li> <a href="#ref-for-dfn-chromaticity-5" title="§ C. Gamma and chromaticity">§ C. Gamma and chromaticity</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-composited" aria-label="Links in this document to definition: composite (verb)"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-composited" aria-label="Permalink for definition: composite (verb). Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-composited-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-composited-2" title="§ 4.9.3 Output buffer">§ 4.9.3 Output buffer</a> </li><li> <a href="#ref-for-dfn-composited-3" title="§ 6.2 Alpha representation">§ 6.2 Alpha representation</a> <a href="#ref-for-dfn-composited-4" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-composited-5" title="§ 11.3.4.4 sPLT Suggested palette">§ 11.3.4.4 sPLT Suggested palette</a> </li><li> <a href="#ref-for-dfn-composited-6" title="§ 11.3.6.2 fcTL Frame Control Chunk">§ 11.3.6.2 fcTL Frame Control Chunk</a> </li><li> <a href="#ref-for-dfn-composited-7" title="§ 12.5 Suggested palettes">§ 12.5 Suggested palettes</a> <a href="#ref-for-dfn-composited-8" title="Reference 2">(2)</a> <a href="#ref-for-dfn-composited-9" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-dfn-composited-10" title="§ 13.15 Background color">§ 13.15 Background color</a> </li><li> <a href="#ref-for-dfn-composited-11" title="§ 13.16 Alpha channel processing">§ 13.16 Alpha channel processing</a> <a href="#ref-for-dfn-composited-12" title="Reference 2">(2)</a> <a href="#ref-for-dfn-composited-13" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-dfn-composited-14" title="§ 13.17 Histogram and suggested palette usage">§ 13.17 Histogram and suggested palette usage</a> <a href="#ref-for-dfn-composited-15" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-datastream" aria-label="Links in this document to definition: datastream"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-datastream" aria-label="Permalink for definition: datastream. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-datastream-1" title="§ 5.2 PNG signature">§ 5.2 PNG signature</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-deflate" aria-label="Links in this document to definition: deflate"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-deflate" aria-label="Permalink for definition: deflate. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-deflate-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-deflate-2" title="§ 10.1 Compression method 0">§ 10.1 Compression method 0</a> <a href="#ref-for-dfn-deflate-3" title="Reference 2">(2)</a> <a href="#ref-for-dfn-deflate-4" title="Reference 3">(3)</a> <a href="#ref-for-dfn-deflate-5" title="Reference 4">(4)</a> <a href="#ref-for-dfn-deflate-6" title="Reference 5">(5)</a> <a href="#ref-for-dfn-deflate-7" title="Reference 6">(6)</a> <a href="#ref-for-dfn-deflate-8" title="Reference 7">(7)</a> </li><li> <a href="#ref-for-dfn-deflate-9" title="§ 10.2 Compression of the sequence of filtered scanlines">§ 10.2 Compression of the sequence of filtered scanlines</a> <a href="#ref-for-dfn-deflate-10" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-deflate-11" title="§ 11.2.1 IHDR Image header">§ 11.2.1 IHDR Image header</a> </li><li> <a href="#ref-for-dfn-deflate-12" title="§ 11.3.2.3 iCCP Embedded ICC profile">§ 11.3.2.3 iCCP Embedded ICC profile</a> </li><li> <a href="#ref-for-dfn-deflate-13" title="§ 11.3.3.1 Keywords and text strings">§ 11.3.3.1 Keywords and text strings</a> </li><li> <a href="#ref-for-dfn-deflate-14" title="§ 11.3.3.3 zTXt Compressed textual data">§ 11.3.3.3 zTXt Compressed textual data</a> </li><li> <a href="#ref-for-dfn-deflate-15" title="§ 11.3.3.4 iTXt International textual data">§ 11.3.3.4 iTXt International textual data</a> </li><li> <a href="#ref-for-dfn-deflate-16" title="§ 13.1 Error handling">§ 13.1 Error handling</a> </li><li> <a href="#ref-for-dfn-deflate-17" title="§ 13.8 Decompression">§ 13.8 Decompression</a> </li><li> <a href="#ref-for-dfn-deflate-18" title="§ E.2 PNG web site">§ E.2 PNG web site</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-frame" aria-label="Links in this document to definition: frame"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-frame" aria-label="Permalink for definition: frame. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-frame-1" title="§ Introduction">§ Introduction</a> </li><li> <a href="#ref-for-dfn-frame-2" title="§ 11.3.2.8 cLLI Content Light Level Information">§ 11.3.2.8 cLLI Content Light Level Information</a> <a href="#ref-for-dfn-frame-3" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-frame-buffer" aria-label="Links in this document to definition: frame buffer"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-frame-buffer" aria-label="Permalink for definition: frame buffer. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-frame-buffer-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-frame-buffer-2" title="§ 13.12 Sample depth rescaling">§ 13.12 Sample depth rescaling</a> </li><li> <a href="#ref-for-dfn-frame-buffer-3" title="§ 13.13 Decoder gamma handling">§ 13.13 Decoder gamma handling</a> <a href="#ref-for-dfn-frame-buffer-4" title="Reference 2">(2)</a> <a href="#ref-for-dfn-frame-buffer-5" title="Reference 3">(3)</a> <a href="#ref-for-dfn-frame-buffer-6" title="Reference 4">(4)</a> <a href="#ref-for-dfn-frame-buffer-7" title="Reference 5">(5)</a> </li><li> <a href="#ref-for-dfn-frame-buffer-8" title="§ 13.16 Alpha channel processing">§ 13.16 Alpha channel processing</a> <a href="#ref-for-dfn-frame-buffer-9" title="Reference 2">(2)</a> <a href="#ref-for-dfn-frame-buffer-10" title="Reference 3">(3)</a> <a href="#ref-for-dfn-frame-buffer-11" title="Reference 4">(4)</a> </li><li> <a href="#ref-for-dfn-frame-buffer-12" title="§ 13.17 Histogram and suggested palette usage">§ 13.17 Histogram and suggested palette usage</a> </li><li> <a href="#ref-for-dfn-frame-buffer-13" title="§ C. Gamma and chromaticity">§ C. Gamma and chromaticity</a> <a href="#ref-for-dfn-frame-buffer-14" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-fully-transparent-black" aria-label="Links in this document to definition: fully transparent black"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-fully-transparent-black" aria-label="Permalink for definition: fully transparent black. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-fully-transparent-black-1" title="§ 4.9.1 Structure">§ 4.9.1 Structure</a> <a href="#ref-for-dfn-fully-transparent-black-2" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-gamma-value" aria-label="Links in this document to definition: gamma value"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-gamma-value" aria-label="Permalink for definition: gamma value. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-gamma-value-1" title="§ 4.3 Color spaces">§ 4.3 Color spaces</a> </li><li> <a href="#ref-for-dfn-gamma-value-2" title="§ 4.7 Additional information">§ 4.7 Additional information</a> </li><li> <a href="#ref-for-dfn-gamma-value-3" title="§ 11.3.2.2 gAMA Image gamma">§ 11.3.2.2 gAMA Image gamma</a> <a href="#ref-for-dfn-gamma-value-4" title="Reference 2">(2)</a> <a href="#ref-for-dfn-gamma-value-5" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-dfn-gamma-value-6" title="§ 11.3.4.4 sPLT Suggested palette">§ 11.3.4.4 sPLT Suggested palette</a> </li><li> <a href="#ref-for-dfn-gamma-value-7" title="§ 12.1 Encoder gamma handling">§ 12.1 Encoder gamma handling</a> <a href="#ref-for-dfn-gamma-value-8" title="Reference 2">(2)</a> <a href="#ref-for-dfn-gamma-value-9" title="Reference 3">(3)</a> <a href="#ref-for-dfn-gamma-value-10" title="Reference 4">(4)</a> <a href="#ref-for-dfn-gamma-value-11" title="Reference 5">(5)</a> <a href="#ref-for-dfn-gamma-value-12" title="Reference 6">(6)</a> <a href="#ref-for-dfn-gamma-value-13" title="Reference 7">(7)</a> <a href="#ref-for-dfn-gamma-value-14" title="Reference 8">(8)</a> <a href="#ref-for-dfn-gamma-value-15" title="Reference 9">(9)</a> <a href="#ref-for-dfn-gamma-value-16" title="Reference 10">(10)</a> <a href="#ref-for-dfn-gamma-value-17" title="Reference 11">(11)</a> </li><li> <a href="#ref-for-dfn-gamma-value-18" title="§ 13.13 Decoder gamma handling">§ 13.13 Decoder gamma handling</a> <a href="#ref-for-dfn-gamma-value-19" title="Reference 2">(2)</a> <a href="#ref-for-dfn-gamma-value-20" title="Reference 3">(3)</a> <a href="#ref-for-dfn-gamma-value-21" title="Reference 4">(4)</a> <a href="#ref-for-dfn-gamma-value-22" title="Reference 5">(5)</a> <a href="#ref-for-dfn-gamma-value-23" title="Reference 6">(6)</a> <a href="#ref-for-dfn-gamma-value-24" title="Reference 7">(7)</a> </li><li> <a href="#ref-for-dfn-gamma-value-25" title="§ 13.16 Alpha channel processing">§ 13.16 Alpha channel processing</a> <a href="#ref-for-dfn-gamma-value-26" title="Reference 2">(2)</a> <a href="#ref-for-dfn-gamma-value-27" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-dfn-gamma-value-28" title="§ C. Gamma and chromaticity">§ C. Gamma and chromaticity</a> <a href="#ref-for-dfn-gamma-value-29" title="Reference 2">(2)</a> <a href="#ref-for-dfn-gamma-value-30" title="Reference 3">(3)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-gamma" aria-label="Links in this document to definition: gamma"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-gamma" aria-label="Permalink for definition: gamma. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-gamma-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-gamma-2" title="§ 4.3 Color spaces">§ 4.3 Color spaces</a> <a href="#ref-for-dfn-gamma-3" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-gamma-4" title="§ 12.1 Encoder gamma handling">§ 12.1 Encoder gamma handling</a> <a href="#ref-for-dfn-gamma-5" title="Reference 2">(2)</a> <a href="#ref-for-dfn-gamma-6" title="Reference 3">(3)</a> <a href="#ref-for-dfn-gamma-7" title="Reference 4">(4)</a> <a href="#ref-for-dfn-gamma-8" title="Reference 5">(5)</a> <a href="#ref-for-dfn-gamma-9" title="Reference 6">(6)</a> <a href="#ref-for-dfn-gamma-10" title="Reference 7">(7)</a> <a href="#ref-for-dfn-gamma-11" title="Reference 8">(8)</a> </li><li> <a href="#ref-for-dfn-gamma-12" title="§ 12.2 Encoder color handling">§ 12.2 Encoder color handling</a> </li><li> <a href="#ref-for-dfn-gamma-13" title="§ 13.12 Sample depth rescaling">§ 13.12 Sample depth rescaling</a> <a href="#ref-for-dfn-gamma-14" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-gamma-15" title="§ 13.13 Decoder gamma handling">§ 13.13 Decoder gamma handling</a> <a href="#ref-for-dfn-gamma-16" title="Reference 2">(2)</a> <a href="#ref-for-dfn-gamma-17" title="Reference 3">(3)</a> <a href="#ref-for-dfn-gamma-18" title="Reference 4">(4)</a> </li><li> <a href="#ref-for-dfn-gamma-19" title="§ 13.14 Decoder color handling">§ 13.14 Decoder color handling</a> <a href="#ref-for-dfn-gamma-20" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-gamma-21" title="§ 13.16 Alpha channel processing">§ 13.16 Alpha channel processing</a> <a href="#ref-for-dfn-gamma-22" title="Reference 2">(2)</a> <a href="#ref-for-dfn-gamma-23" title="Reference 3">(3)</a> <a href="#ref-for-dfn-gamma-24" title="Reference 4">(4)</a> <a href="#ref-for-dfn-gamma-25" title="Reference 5">(5)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-hdr" aria-label="Links in this document to definition: HDR"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-hdr" aria-label="Permalink for definition: HDR. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-hdr-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-hdr-2" title="§ 4.7 Additional information">§ 4.7 Additional information</a> </li><li> <a href="#ref-for-dfn-hdr-3" title="§ 11.3.2.7 mDCV Mastering Display Color Volume">§ 11.3.2.7 mDCV Mastering Display Color Volume</a> <a href="#ref-for-dfn-hdr-4" title="Reference 2">(2)</a> <a href="#ref-for-dfn-hdr-5" title="Reference 3">(3)</a> <a href="#ref-for-dfn-hdr-6" title="Reference 4">(4)</a> </li><li> <a href="#ref-for-dfn-hdr-7" title="§ 11.3.2.8 cLLI Content Light Level Information">§ 11.3.2.8 cLLI Content Light Level Information</a> </li><li> <a href="#ref-for-dfn-hdr-8" title="§ F.5 Changes since the First Public Working Draft of 25 October 2022 (Third Edition)">§ F.5 Changes since the First Public Working Draft of 25 October 2022 (Third Edition)</a> <a href="#ref-for-dfn-hdr-9" title="Reference 2">(2)</a> <a href="#ref-for-dfn-hdr-10" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-dfn-hdr-11" title="§ F.6 Changes since the W3C Recommendation of 10 November 2003 (PNG Second Edition)">§ F.6 Changes since the W3C Recommendation of 10 November 2003 (PNG Second Edition)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-hlg" aria-label="Links in this document to definition: HLG"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-hlg" aria-label="Permalink for definition: HLG. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-hlg-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-hlg-2" title="§ 11.3.2.6 cICP Coding-independent code points for video signal type identification">§ 11.3.2.6 cICP Coding-independent code points for video signal type identification</a> </li><li> <a href="#ref-for-dfn-hlg-3" title="§ 11.3.2.7 mDCV Mastering Display Color Volume">§ 11.3.2.7 mDCV Mastering Display Color Volume</a> <a href="#ref-for-dfn-hlg-4" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-full-range-image" aria-label="Links in this document to definition: full-range image"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-full-range-image" aria-label="Permalink for definition: full-range image. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-full-range-image-1" title="§ 11.3.2.6 cICP Coding-independent code points for video signal type identification">§ 11.3.2.6 cICP Coding-independent code points for video signal type identification</a> <a href="#ref-for-dfn-full-range-image-2" title="Reference 2">(2)</a> <a href="#ref-for-dfn-full-range-image-3" title="Reference 3">(3)</a> <a href="#ref-for-dfn-full-range-image-4" title="Reference 4">(4)</a> <a href="#ref-for-dfn-full-range-image-5" title="Reference 5">(5)</a> <a href="#ref-for-dfn-full-range-image-6" title="Reference 6">(6)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-image-data" aria-label="Links in this document to definition: image data"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-image-data" aria-label="Permalink for definition: image data. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-image-data-1" title="§ 4.6.3 Filtering">§ 4.6.3 Filtering</a> </li><li> <a href="#ref-for-dfn-image-data-2" title="§ 7.3 Filtering">§ 7.3 Filtering</a> <a href="#ref-for-dfn-image-data-3" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-image-data-4" title="§ 9.2 Filter types for filter method 0">§ 9.2 Filter types for filter method 0</a> </li><li> <a href="#ref-for-dfn-image-data-5" title="§ 10.2 Compression of the sequence of filtered scanlines">§ 10.2 Compression of the sequence of filtered scanlines</a> <a href="#ref-for-dfn-image-data-6" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-image-data-7" title="§ 10.3 Other uses of compression">§ 10.3 Other uses of compression</a> </li><li> <a href="#ref-for-dfn-image-data-8" title="§ 11.2.1 IHDR Image header">§ 11.2.1 IHDR Image header</a> <a href="#ref-for-dfn-image-data-9" title="Reference 2">(2)</a> <a href="#ref-for-dfn-image-data-10" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-dfn-image-data-11" title="§ 11.2.2 PLTE Palette">§ 11.2.2 PLTE Palette</a> </li><li> <a href="#ref-for-dfn-image-data-12" title="§ 11.2.3 IDAT Image data">§ 11.2.3 IDAT Image data</a> </li><li> <a href="#ref-for-dfn-image-data-13" title="§ 11.3.4.5 eXIf Exchangeable Image File (Exif) Profile">§ 11.3.4.5 eXIf Exchangeable Image File (Exif) Profile</a> <a href="#ref-for-dfn-image-data-14" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-image-data-15" title="§ 11.3.5.1 tIME Image last-modification time">§ 11.3.5.1 tIME Image last-modification time</a> </li><li> <a href="#ref-for-dfn-image-data-16" title="§ 11.3.6.3 fdAT Frame Data Chunk">§ 11.3.6.3 fdAT Frame Data Chunk</a> </li><li> <a href="#ref-for-dfn-image-data-17" title="§ 12.4 Sample depth scaling">§ 12.4 Sample depth scaling</a> </li><li> <a href="#ref-for-dfn-image-data-18" title="§ 12.5 Suggested palettes">§ 12.5 Suggested palettes</a> </li><li> <a href="#ref-for-dfn-image-data-19" title="§ 12.9 Text chunk processing">§ 12.9 Text chunk processing</a> <a href="#ref-for-dfn-image-data-20" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-image-data-21" title="§ 13.1 Error handling">§ 13.1 Error handling</a> </li><li> <a href="#ref-for-dfn-image-data-22" title="§ 13.8 Decompression">§ 13.8 Decompression</a> <a href="#ref-for-dfn-image-data-23" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-image-data-24" title="§ 13.9 Filtering">§ 13.9 Filtering</a> </li><li> <a href="#ref-for-dfn-image-data-25" title="§ 13.12 Sample depth rescaling">§ 13.12 Sample depth rescaling</a> </li><li> <a href="#ref-for-dfn-image-data-26" title="§ 13.14 Decoder color handling">§ 13.14 Decoder color handling</a> <a href="#ref-for-dfn-image-data-27" title="Reference 2">(2)</a> <a href="#ref-for-dfn-image-data-28" title="Reference 3">(3)</a> <a href="#ref-for-dfn-image-data-29" title="Reference 4">(4)</a> <a href="#ref-for-dfn-image-data-30" title="Reference 5">(5)</a> <a href="#ref-for-dfn-image-data-31" title="Reference 6">(6)</a> </li><li> <a href="#ref-for-dfn-image-data-32" title="§ 13.17 Histogram and suggested palette usage">§ 13.17 Histogram and suggested palette usage</a> <a href="#ref-for-dfn-image-data-33" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-image-data-34" title="§ 14.2 Behavior of PNG editors">§ 14.2 Behavior of PNG editors</a> <a href="#ref-for-dfn-image-data-35" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-image-data-36" title="§ 15.3.3 Conformance of PNG decoders">§ 15.3.3 Conformance of PNG decoders</a> </li><li> <a href="#ref-for-dfn-image-data-37" title="§ C. Gamma and chromaticity">§ C. Gamma and chromaticity</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-interlaced-png-image" aria-label="Links in this document to definition: interlaced PNG image"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-interlaced-png-image" aria-label="Permalink for definition: interlaced PNG image. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-interlaced-png-image-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-lossless" aria-label="Links in this document to definition: lossless"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-lossless" aria-label="Permalink for definition: lossless. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-lossless-1" title="§ Abstract">§ Abstract</a> </li><li> <a href="#ref-for-dfn-lossless-2" title="§ 2. Scope">§ 2. Scope</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-luminance" aria-label="Links in this document to definition: luminance"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-luminance" aria-label="Permalink for definition: luminance. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-luminance-1" title="§ 4.5 PNG image">§ 4.5 PNG image</a> </li><li> <a href="#ref-for-dfn-luminance-2" title="§ 4.7 Additional information">§ 4.7 Additional information</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3LZ77" aria-label="Links in this document to definition: LZ77"> <span class="caret"></span> <div> <a class="self-link" href="#3LZ77" aria-label="Permalink for definition: LZ77. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3LZ77-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-3LZ77-2" title="§ 10.1 Compression method 0">§ 10.1 Compression method 0</a> <a href="#ref-for-3LZ77-3" title="Reference 2">(2)</a> <a href="#ref-for-3LZ77-4" title="Reference 3">(3)</a> <a href="#ref-for-3LZ77-5" title="Reference 4">(4)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-narrow-range-image" aria-label="Links in this document to definition: narrow-range image"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-narrow-range-image" aria-label="Permalink for definition: narrow-range image. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-narrow-range-image-1" title="§ 11.3.2.6 cICP Coding-independent code points for video signal type identification">§ 11.3.2.6 cICP Coding-independent code points for video signal type identification</a> <a href="#ref-for-dfn-narrow-range-image-2" title="Reference 2">(2)</a> <a href="#ref-for-dfn-narrow-range-image-3" title="Reference 3">(3)</a> <a href="#ref-for-dfn-narrow-range-image-4" title="Reference 4">(4)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-network-byte-order" aria-label="Links in this document to definition: network byte order"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-network-byte-order" aria-label="Permalink for definition: network byte order. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-network-byte-order-1" title="§ 7.1 Integers and byte order">§ 7.1 Integers and byte order</a> </li><li> <a href="#ref-for-dfn-network-byte-order-2" title="§ 7.2 Scanlines">§ 7.2 Scanlines</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-pq" aria-label="Links in this document to definition: PQ"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-pq" aria-label="Permalink for definition: PQ. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-pq-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-pq-2" title="§ 11.3.2.6 cICP Coding-independent code points for video signal type identification">§ 11.3.2.6 cICP Coding-independent code points for video signal type identification</a> </li><li> <a href="#ref-for-dfn-pq-3" title="§ 11.3.2.7 mDCV Mastering Display Color Volume">§ 11.3.2.7 mDCV Mastering Display Color Volume</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-png-editor" aria-label="Links in this document to definition: PNG editor"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-png-editor" aria-label="Permalink for definition: PNG editor. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-png-editor-1" title="§ 4.2 Images">§ 4.2 Images</a> </li><li> <a href="#ref-for-dfn-png-editor-2" title="§ 5.4 Chunk naming conventions">§ 5.4 Chunk naming conventions</a> <a href="#ref-for-dfn-png-editor-3" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-png-editor-4" title="§ 12.5 Suggested palettes">§ 12.5 Suggested palettes</a> <a href="#ref-for-dfn-png-editor-5" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-png-editor-6" title="§ 13.1 Error handling">§ 13.1 Error handling</a> </li><li> <a href="#ref-for-dfn-png-editor-7" title="§ 14.2 Behavior of PNG editors">§ 14.2 Behavior of PNG editors</a> <a href="#ref-for-dfn-png-editor-8" title="Reference 2">(2)</a> <a href="#ref-for-dfn-png-editor-9" title="Reference 3">(3)</a> <a href="#ref-for-dfn-png-editor-10" title="Reference 4">(4)</a> <a href="#ref-for-dfn-png-editor-11" title="Reference 5">(5)</a> <a href="#ref-for-dfn-png-editor-12" title="Reference 6">(6)</a> <a href="#ref-for-dfn-png-editor-13" title="Reference 7">(7)</a> <a href="#ref-for-dfn-png-editor-14" title="Reference 8">(8)</a> <a href="#ref-for-dfn-png-editor-15" title="Reference 9">(9)</a> <a href="#ref-for-dfn-png-editor-16" title="Reference 10">(10)</a> <a href="#ref-for-dfn-png-editor-17" title="Reference 11">(11)</a> </li><li> <a href="#ref-for-dfn-png-editor-18" title="§ 14.3.1 Ordering of critical chunks">§ 14.3.1 Ordering of critical chunks</a> </li><li> <a href="#ref-for-dfn-png-editor-19" title="§ 14.3.2 Ordering of ancillary chunks">§ 14.3.2 Ordering of ancillary chunks</a> </li><li> <a href="#ref-for-dfn-png-editor-20" title="§ 15.2.1 Objectives">§ 15.2.1 Objectives</a> </li><li> <a href="#ref-for-dfn-png-editor-21" title="§ 15.2.2 Scope">§ 15.2.2 Scope</a> </li><li> <a href="#ref-for-dfn-png-editor-22" title="§ 15.3.4 Conformance of PNG editors">§ 15.3.4 Conformance of PNG editors</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-png-four-byte-unsigned-integer" aria-label="Links in this document to definition: PNG four-byte unsigned integer"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-png-four-byte-unsigned-integer" aria-label="Permalink for definition: PNG four-byte unsigned integer. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-1" title="§ 5.3 Chunk layout">§ 5.3 Chunk layout</a> </li><li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-2" title="§ 7.1 Integers and byte order">§ 7.1 Integers and byte order</a> </li><li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-3" title="§ 11.2.1 IHDR Image header">§ 11.2.1 IHDR Image header</a> </li><li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-4" title="§ 11.3.2.1 cHRM Primary chromaticities and white point">§ 11.3.2.1 cHRM Primary chromaticities and white point</a> </li><li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-5" title="§ 11.3.2.2 gAMA Image gamma">§ 11.3.2.2 gAMA Image gamma</a> </li><li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-6" title="§ 11.3.2.7 mDCV Mastering Display Color Volume">§ 11.3.2.7 mDCV Mastering Display Color Volume</a> </li><li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-7" title="§ 11.3.2.8 cLLI Content Light Level Information">§ 11.3.2.8 cLLI Content Light Level Information</a> </li><li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-8" title="§ 11.3.4.3 pHYs Physical pixel dimensions">§ 11.3.4.3 pHYs Physical pixel dimensions</a> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-9" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-10" title="§ 11.3.6.1 acTL Animation Control Chunk">§ 11.3.6.1 acTL Animation Control Chunk</a> </li><li> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-11" title="§ 11.3.6.2 fcTL Frame Control Chunk">§ 11.3.6.2 fcTL Frame Control Chunk</a> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-12" title="Reference 2">(2)</a> <a href="#ref-for-dfn-png-four-byte-unsigned-integer-13" title="Reference 3">(3)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-png-two-byte-unsigned-integer" aria-label="Links in this document to definition: PNG two-byte unsigned integer"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-png-two-byte-unsigned-integer" aria-label="Permalink for definition: PNG two-byte unsigned integer. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-png-two-byte-unsigned-integer-1" title="§ 11.3.2.7 mDCV Mastering Display Color Volume">§ 11.3.2.7 mDCV Mastering Display Color Volume</a> <a href="#ref-for-dfn-png-two-byte-unsigned-integer-2" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-sample" aria-label="Links in this document to definition: sample"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-sample" aria-label="Permalink for definition: sample. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-sample-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-sample-2" title="§ 4.5 PNG image">§ 4.5 PNG image</a> <a href="#ref-for-dfn-sample-3" title="Reference 2">(2)</a> <a href="#ref-for-dfn-sample-4" title="Reference 3">(3)</a> <a href="#ref-for-dfn-sample-5" title="Reference 4">(4)</a> <a href="#ref-for-dfn-sample-6" title="Reference 5">(5)</a> <a href="#ref-for-dfn-sample-7" title="Reference 6">(6)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-scanline" aria-label="Links in this document to definition: scanline"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-scanline" aria-label="Permalink for definition: scanline. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-scanline-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-scanline-2" title="§ 7.3 Filtering">§ 7.3 Filtering</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-sdr" aria-label="Links in this document to definition: SDR"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-sdr" aria-label="Permalink for definition: SDR. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-sdr-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-sdr-2" title="§ 4.7 Additional information">§ 4.7 Additional information</a> </li><li> <a href="#ref-for-dfn-sdr-3" title="§ 11.3.2.7 mDCV Mastering Display Color Volume">§ 11.3.2.7 mDCV Mastering Display Color Volume</a> <a href="#ref-for-dfn-sdr-4" title="Reference 2">(2)</a> <a href="#ref-for-dfn-sdr-5" title="Reference 3">(3)</a> <a href="#ref-for-dfn-sdr-6" title="Reference 4">(4)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-stop" aria-label="Links in this document to definition: stop"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-stop" aria-label="Permalink for definition: stop. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-stop-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> <a href="#ref-for-dfn-stop-2" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-transfer-function" aria-label="Links in this document to definition: transfer function"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-transfer-function" aria-label="Permalink for definition: transfer function. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-transfer-function-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> <a href="#ref-for-dfn-transfer-function-2" title="Reference 2">(2)</a> <a href="#ref-for-dfn-transfer-function-3" title="Reference 3">(3)</a> <a href="#ref-for-dfn-transfer-function-4" title="Reference 4">(4)</a> <a href="#ref-for-dfn-transfer-function-5" title="Reference 5">(5)</a> <a href="#ref-for-dfn-transfer-function-6" title="Reference 6">(6)</a> </li><li> <a href="#ref-for-dfn-transfer-function-7" title="§ 4.7 Additional information">§ 4.7 Additional information</a> </li><li> <a href="#ref-for-dfn-transfer-function-8" title="§ 11.3.2.6 cICP Coding-independent code points for video signal type identification">§ 11.3.2.6 cICP Coding-independent code points for video signal type identification</a> <a href="#ref-for-dfn-transfer-function-9" title="Reference 2">(2)</a> <a href="#ref-for-dfn-transfer-function-10" title="Reference 3">(3)</a> <a href="#ref-for-dfn-transfer-function-11" title="Reference 4">(4)</a> </li><li> <a href="#ref-for-dfn-transfer-function-12" title="§ 12.1 Encoder gamma handling">§ 12.1 Encoder gamma handling</a> <a href="#ref-for-dfn-transfer-function-13" title="Reference 2">(2)</a> <a href="#ref-for-dfn-transfer-function-14" title="Reference 3">(3)</a> <a href="#ref-for-dfn-transfer-function-15" title="Reference 4">(4)</a> <a href="#ref-for-dfn-transfer-function-16" title="Reference 5">(5)</a> </li><li> <a href="#ref-for-dfn-transfer-function-17" title="§ 13.13 Decoder gamma handling">§ 13.13 Decoder gamma handling</a> <a href="#ref-for-dfn-transfer-function-18" title="Reference 2">(2)</a> <a href="#ref-for-dfn-transfer-function-19" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-dfn-transfer-function-20" title="§ C. Gamma and chromaticity">§ C. Gamma and chromaticity</a> <a href="#ref-for-dfn-transfer-function-21" title="Reference 2">(2)</a> <a href="#ref-for-dfn-transfer-function-22" title="Reference 3">(3)</a> <a href="#ref-for-dfn-transfer-function-23" title="Reference 4">(4)</a> <a href="#ref-for-dfn-transfer-function-24" title="Reference 5">(5)</a> <a href="#ref-for-dfn-transfer-function-25" title="Reference 6">(6)</a> <a href="#ref-for-dfn-transfer-function-26" title="Reference 7">(7)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-white-point" aria-label="Links in this document to definition: white point"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-white-point" aria-label="Permalink for definition: white point. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-white-point-1" title="§ 4.3 Color spaces">§ 4.3 Color spaces</a> </li><li> <a href="#ref-for-dfn-white-point-2" title="§ 11.3.2.1 cHRM Primary chromaticities and white point">§ 11.3.2.1 cHRM Primary chromaticities and white point</a> </li><li> <a href="#ref-for-dfn-white-point-3" title="§ 11.3.2.5 sRGB Standard RGB color space">§ 11.3.2.5 sRGB Standard RGB color space</a> </li><li> <a href="#ref-for-dfn-white-point-4" title="§ 12.2 Encoder color handling">§ 12.2 Encoder color handling</a> <a href="#ref-for-dfn-white-point-5" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-zlib" aria-label="Links in this document to definition: zlib"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-zlib" aria-label="Permalink for definition: zlib. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-zlib-1" title="§ 10.1 Compression method 0">§ 10.1 Compression method 0</a> <a href="#ref-for-dfn-zlib-2" title="Reference 2">(2)</a> <a href="#ref-for-dfn-zlib-3" title="Reference 3">(3)</a> <a href="#ref-for-dfn-zlib-4" title="Reference 4">(4)</a> <a href="#ref-for-dfn-zlib-5" title="Reference 5">(5)</a> <a href="#ref-for-dfn-zlib-6" title="Reference 6">(6)</a> <a href="#ref-for-dfn-zlib-7" title="Reference 7">(7)</a> </li><li> <a href="#ref-for-dfn-zlib-8" title="§ 10.2 Compression of the sequence of filtered scanlines">§ 10.2 Compression of the sequence of filtered scanlines</a> <a href="#ref-for-dfn-zlib-9" title="Reference 2">(2)</a> <a href="#ref-for-dfn-zlib-10" title="Reference 3">(3)</a> <a href="#ref-for-dfn-zlib-11" title="Reference 4">(4)</a> <a href="#ref-for-dfn-zlib-12" title="Reference 5">(5)</a> </li><li> <a href="#ref-for-dfn-zlib-13" title="§ 10.3 Other uses of compression">§ 10.3 Other uses of compression</a> </li><li> <a href="#ref-for-dfn-zlib-14" title="§ 11.3.2.3 iCCP Embedded ICC profile">§ 11.3.2.3 iCCP Embedded ICC profile</a> </li><li> <a href="#ref-for-dfn-zlib-15" title="§ 11.3.3.1 Keywords and text strings">§ 11.3.3.1 Keywords and text strings</a> </li><li> <a href="#ref-for-dfn-zlib-16" title="§ 11.3.3.3 zTXt Compressed textual data">§ 11.3.3.3 zTXt Compressed textual data</a> </li><li> <a href="#ref-for-dfn-zlib-17" title="§ 11.3.3.4 iTXt International textual data">§ 11.3.3.4 iTXt International textual data</a> </li><li> <a href="#ref-for-dfn-zlib-18" title="§ 13.8 Decompression">§ 13.8 Decompression</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-eotf" aria-label="Links in this document to definition: EOTF"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-eotf" aria-label="Permalink for definition: EOTF. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-eotf-1" title="§ 11.3.2.6 cICP Coding-independent code points for video signal type identification">§ 11.3.2.6 cICP Coding-independent code points for video signal type identification</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-oetf" aria-label="Links in this document to definition: OETF"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-oetf" aria-label="Permalink for definition: OETF. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-oetf-1" title="§ 11.3.2.6 cICP Coding-independent code points for video signal type identification">§ 11.3.2.6 cICP Coding-independent code points for video signal type identification</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-static-image" aria-label="Links in this document to definition: static image"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-static-image" aria-label="Permalink for definition: static image. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-static-image-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-dfn-static-image-2" title="§ 4.1 Static and Animated images">§ 4.1 Static and Animated images</a> <a href="#ref-for-dfn-static-image-3" title="Reference 2">(2)</a> <a href="#ref-for-dfn-static-image-4" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-dfn-static-image-5" title="§ 4.7 Additional information">§ 4.7 Additional information</a> </li><li> <a href="#ref-for-dfn-static-image-6" title="§ Introduction">§ Introduction</a> </li><li> <a href="#ref-for-dfn-static-image-7" title="§ 11.3.6.3 fdAT Frame Data Chunk">§ 11.3.6.3 fdAT Frame Data Chunk</a> <a href="#ref-for-dfn-static-image-8" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-animated-png" aria-label="Links in this document to definition: Animated PNG"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-animated-png" aria-label="Permalink for definition: Animated PNG. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li>Not referenced in this document.</li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-animated-image" aria-label="Links in this document to definition: animated image"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-animated-image" aria-label="Permalink for definition: animated image. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-animated-image-1" title="§ 4.1 Static and Animated images">§ 4.1 Static and Animated images</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3sourceImage" aria-label="Links in this document to definition: Source image"> <span class="caret"></span> <div> <a class="self-link" href="#3sourceImage" aria-label="Permalink for definition: Source image. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3sourceImage-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3referenceImage" aria-label="Links in this document to definition: Reference image"> <span class="caret"></span> <div> <a class="self-link" href="#3referenceImage" aria-label="Permalink for definition: Reference image. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3referenceImage-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> <a href="#ref-for-3referenceImage-2" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3referenceImage-3" title="§ 4.2 Images">§ 4.2 Images</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3pixel" aria-label="Links in this document to definition: pixels"> <span class="caret"></span> <div> <a class="self-link" href="#3pixel" aria-label="Permalink for definition: pixels. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3pixel-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> <a href="#ref-for-3pixel-2" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3pixel-3" title="§ 4.5 PNG image">§ 4.5 PNG image</a> <a href="#ref-for-3pixel-4" title="Reference 2">(2)</a> <a href="#ref-for-3pixel-5" title="Reference 3">(3)</a> <a href="#ref-for-3pixel-6" title="Reference 4">(4)</a> <a href="#ref-for-3pixel-7" title="Reference 5">(5)</a> <a href="#ref-for-3pixel-8" title="Reference 6">(6)</a> <a href="#ref-for-3pixel-9" title="Reference 7">(7)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3channel" aria-label="Links in this document to definition: channel"> <span class="caret"></span> <div> <a class="self-link" href="#3channel" aria-label="Permalink for definition: channel. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3channel-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3alpha" aria-label="Links in this document to definition: alpha"> <span class="caret"></span> <div> <a class="self-link" href="#3alpha" aria-label="Permalink for definition: alpha. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3alpha-1" title="§ 4.5 PNG image">§ 4.5 PNG image</a> <a href="#ref-for-3alpha-2" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3PNGimage" aria-label="Links in this document to definition: PNG image"> <span class="caret"></span> <div> <a class="self-link" href="#3PNGimage" aria-label="Permalink for definition: PNG image. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3PNGimage-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-3PNGimage-2" title="§ 5.1 PNG datastream">§ 5.1 PNG datastream</a> </li><li> <a href="#ref-for-3PNGimage-3" title="§ 11.3.2.1 cHRM Primary chromaticities and white point">§ 11.3.2.1 cHRM Primary chromaticities and white point</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3deliveredImage" aria-label="Links in this document to definition: Delivered image"> <span class="caret"></span> <div> <a class="self-link" href="#3deliveredImage" aria-label="Permalink for definition: Delivered image. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3deliveredImage-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li><li> <a href="#ref-for-3deliveredImage-2" title="§ 4.2 Images">§ 4.2 Images</a> <a href="#ref-for-3deliveredImage-3" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3alphaSeparation" aria-label="Links in this document to definition: Alpha separation"> <span class="caret"></span> <div> <a class="self-link" href="#3alphaSeparation" aria-label="Permalink for definition: Alpha separation. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3alphaSeparation-1" title="§ 4.2 Images">§ 4.2 Images</a> </li><li> <a href="#ref-for-3alphaSeparation-2" title="§ Introduction">§ Introduction</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3indexing" aria-label="Links in this document to definition: indexing"> <span class="caret"></span> <div> <a class="self-link" href="#3indexing" aria-label="Permalink for definition: indexing. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3indexing-1" title="§ 4.2 Images">§ 4.2 Images</a> </li><li> <a href="#ref-for-3indexing-2" title="§ Introduction">§ Introduction</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3indexedColour" aria-label="Links in this document to definition: indexed-color"> <span class="caret"></span> <div> <a class="self-link" href="#3indexedColour" aria-label="Permalink for definition: indexed-color. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3indexedColour-1" title="§ Abstract">§ Abstract</a> </li><li> <a href="#ref-for-3indexedColour-2" title="§ 1. Introduction">§ 1. Introduction</a> </li><li> <a href="#ref-for-3indexedColour-3" title="§ 4.4.2 Indexing">§ 4.4.2 Indexing</a> <a href="#ref-for-3indexedColour-4" title="Reference 2">(2)</a> <a href="#ref-for-3indexedColour-5" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-3indexedColour-6" title="§ 4.5 PNG image">§ 4.5 PNG image</a> <a href="#ref-for-3indexedColour-7" title="Reference 2">(2)</a> <a href="#ref-for-3indexedColour-8" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-3indexedColour-9" title="§ 6.2 Alpha representation">§ 6.2 Alpha representation</a> <a href="#ref-for-3indexedColour-10" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3indexedColour-11" title="§ 7.2 Scanlines">§ 7.2 Scanlines</a> </li><li> <a href="#ref-for-3indexedColour-12" title="§ 11.2.1 IHDR Image header">§ 11.2.1 IHDR Image header</a> </li><li> <a href="#ref-for-3indexedColour-13" title="§ 11.3.1.1 tRNS Transparency">§ 11.3.1.1 tRNS Transparency</a> </li><li> <a href="#ref-for-3indexedColour-14" title="§ 11.3.2.4 sBIT Significant bits">§ 11.3.2.4 sBIT Significant bits</a> </li><li> <a href="#ref-for-3indexedColour-15" title="§ 11.3.4.1 bKGD Background color">§ 11.3.4.1 bKGD Background color</a> </li><li> <a href="#ref-for-3indexedColour-16" title="§ 12.5 Suggested palettes">§ 12.5 Suggested palettes</a> </li><li> <a href="#ref-for-3indexedColour-17" title="§ 12.7 Filter selection">§ 12.7 Filter selection</a> </li><li> <a href="#ref-for-3indexedColour-18" title="§ 13.11 Truecolor image handling">§ 13.11 Truecolor image handling</a> </li><li> <a href="#ref-for-3indexedColour-19" title="§ 13.15 Background color">§ 13.15 Background color</a> </li><li> <a href="#ref-for-3indexedColour-20" title="§ 13.16 Alpha channel processing">§ 13.16 Alpha channel processing</a> </li><li> <a href="#ref-for-3indexedColour-21" title="§ 15.3.4 Conformance of PNG editors">§ 15.3.4 Conformance of PNG editors</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3palette" aria-label="Links in this document to definition: palette"> <span class="caret"></span> <div> <a class="self-link" href="#3palette" aria-label="Permalink for definition: palette. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3palette-1" title="§ Introduction">§ Introduction</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3alphaTable" aria-label="Links in this document to definition: alpha table"> <span class="caret"></span> <div> <a class="self-link" href="#3alphaTable" aria-label="Permalink for definition: alpha table. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3alphaTable-1" title="§ Introduction">§ Introduction</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3RGBmerging" aria-label="Links in this document to definition: RGB merging"> <span class="caret"></span> <div> <a class="self-link" href="#3RGBmerging" aria-label="Permalink for definition: RGB merging. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3RGBmerging-1" title="§ 4.2 Images">§ 4.2 Images</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3alphaCompaction" aria-label="Links in this document to definition: Alpha compaction"> <span class="caret"></span> <div> <a class="self-link" href="#3alphaCompaction" aria-label="Permalink for definition: Alpha compaction. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3alphaCompaction-1" title="§ 4.2 Images">§ 4.2 Images</a> </li><li> <a href="#ref-for-3alphaCompaction-2" title="§ Introduction">§ Introduction</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3sampleDepthScaling" aria-label="Links in this document to definition: Sample depth scaling"> <span class="caret"></span> <div> <a class="self-link" href="#3sampleDepthScaling" aria-label="Permalink for definition: Sample depth scaling. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3sampleDepthScaling-1" title="§ 4.2 Images">§ 4.2 Images</a> </li><li> <a href="#ref-for-3sampleDepthScaling-2" title="§ 4.4.5 Sample depth scaling">§ 4.4.5 Sample depth scaling</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-truecolor-with-alpha" aria-label="Links in this document to definition: Truecolor with alpha"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-truecolor-with-alpha" aria-label="Permalink for definition: Truecolor with alpha. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-truecolor-with-alpha-1" title="§ 4.5 PNG image">§ 4.5 PNG image</a> </li><li> <a href="#ref-for-dfn-truecolor-with-alpha-2" title="§ 6.2 Alpha representation">§ 6.2 Alpha representation</a> </li><li> <a href="#ref-for-dfn-truecolor-with-alpha-3" title="§ 11.2.2 PLTE Palette">§ 11.2.2 PLTE Palette</a> </li><li> <a href="#ref-for-dfn-truecolor-with-alpha-4" title="§ 11.3.4.1 bKGD Background color">§ 11.3.4.1 bKGD Background color</a> </li><li> <a href="#ref-for-dfn-truecolor-with-alpha-5" title="§ 12.5 Suggested palettes">§ 12.5 Suggested palettes</a> <a href="#ref-for-dfn-truecolor-with-alpha-6" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-truecolor-with-alpha-7" title="§ 13.17 Histogram and suggested palette usage">§ 13.17 Histogram and suggested palette usage</a> </li><li> <a href="#ref-for-dfn-truecolor-with-alpha-8" title="§ 15.3.3 Conformance of PNG decoders">§ 15.3.3 Conformance of PNG decoders</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-greyscale-with-alpha" aria-label="Links in this document to definition: Greyscale with alpha"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-greyscale-with-alpha" aria-label="Permalink for definition: Greyscale with alpha. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-greyscale-with-alpha-1" title="§ 4.5 PNG image">§ 4.5 PNG image</a> </li><li> <a href="#ref-for-dfn-greyscale-with-alpha-2" title="§ 6.2 Alpha representation">§ 6.2 Alpha representation</a> </li><li> <a href="#ref-for-dfn-greyscale-with-alpha-3" title="§ 11.3.4.1 bKGD Background color">§ 11.3.4.1 bKGD Background color</a> </li><li> <a href="#ref-for-dfn-greyscale-with-alpha-4" title="§ 15.3.3 Conformance of PNG decoders">§ 15.3.3 Conformance of PNG decoders</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3truecolour" aria-label="Links in this document to definition: Truecolor"> <span class="caret"></span> <div> <a class="self-link" href="#3truecolour" aria-label="Permalink for definition: Truecolor. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3truecolour-1" title="§ Abstract">§ Abstract</a> </li><li> <a href="#ref-for-3truecolour-2" title="§ 1. Introduction">§ 1. Introduction</a> </li><li> <a href="#ref-for-3truecolour-3" title="§ 4.5 PNG image">§ 4.5 PNG image</a> </li><li> <a href="#ref-for-3truecolour-4" title="§ 6.1 Color types and values">§ 6.1 Color types and values</a> <a href="#ref-for-3truecolour-5" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3truecolour-6" title="§ 6.2 Alpha representation">§ 6.2 Alpha representation</a> <a href="#ref-for-3truecolour-7" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3truecolour-8" title="§ 11.2.2 PLTE Palette">§ 11.2.2 PLTE Palette</a> <a href="#ref-for-3truecolour-9" title="Reference 2">(2)</a> <a href="#ref-for-3truecolour-10" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-3truecolour-11" title="§ 11.3.1.1 tRNS Transparency">§ 11.3.1.1 tRNS Transparency</a> <a href="#ref-for-3truecolour-12" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3truecolour-13" title="§ 11.3.4.1 bKGD Background color">§ 11.3.4.1 bKGD Background color</a> </li><li> <a href="#ref-for-3truecolour-14" title="§ 11.3.4.2 hIST Image histogram">§ 11.3.4.2 hIST Image histogram</a> </li><li> <a href="#ref-for-3truecolour-15" title="§ 12.5 Suggested palettes">§ 12.5 Suggested palettes</a> <a href="#ref-for-3truecolour-16" title="Reference 2">(2)</a> <a href="#ref-for-3truecolour-17" title="Reference 3">(3)</a> <a href="#ref-for-3truecolour-18" title="Reference 4">(4)</a> </li><li> <a href="#ref-for-3truecolour-19" title="§ 12.7 Filter selection">§ 12.7 Filter selection</a> <a href="#ref-for-3truecolour-20" title="Reference 2">(2)</a> <a href="#ref-for-3truecolour-21" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-3truecolour-22" title="§ 13.1 Error handling">§ 13.1 Error handling</a> </li><li> <a href="#ref-for-3truecolour-23" title="§ 13.11 Truecolor image handling">§ 13.11 Truecolor image handling</a> <a href="#ref-for-3truecolour-24" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3truecolour-25" title="§ 13.16 Alpha channel processing">§ 13.16 Alpha channel processing</a> </li><li> <a href="#ref-for-3truecolour-26" title="§ 13.17 Histogram and suggested palette usage">§ 13.17 Histogram and suggested palette usage</a> <a href="#ref-for-3truecolour-27" title="Reference 2">(2)</a> <a href="#ref-for-3truecolour-28" title="Reference 3">(3)</a> <a href="#ref-for-3truecolour-29" title="Reference 4">(4)</a> <a href="#ref-for-3truecolour-30" title="Reference 5">(5)</a> <a href="#ref-for-3truecolour-31" title="Reference 6">(6)</a> </li><li> <a href="#ref-for-3truecolour-32" title="§ 14.2 Behavior of PNG editors">§ 14.2 Behavior of PNG editors</a> </li><li> <a href="#ref-for-3truecolour-33" title="§ 15.3.3 Conformance of PNG decoders">§ 15.3.3 Conformance of PNG decoders</a> <a href="#ref-for-3truecolour-34" title="Reference 2">(2)</a> <a href="#ref-for-3truecolour-35" title="Reference 3">(3)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-greyscale" aria-label="Links in this document to definition: Greyscale"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-greyscale" aria-label="Permalink for definition: Greyscale. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-greyscale-1" title="§ Abstract">§ Abstract</a> </li><li> <a href="#ref-for-dfn-greyscale-2" title="§ 1. Introduction">§ 1. Introduction</a> </li><li> <a href="#ref-for-dfn-greyscale-3" title="§ 4.5 PNG image">§ 4.5 PNG image</a> </li><li> <a href="#ref-for-dfn-greyscale-4" title="§ 6.1 Color types and values">§ 6.1 Color types and values</a> </li><li> <a href="#ref-for-dfn-greyscale-5" title="§ 6.2 Alpha representation">§ 6.2 Alpha representation</a> <a href="#ref-for-dfn-greyscale-6" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-greyscale-7" title="§ 11.3.1.1 tRNS Transparency">§ 11.3.1.1 tRNS Transparency</a> <a href="#ref-for-dfn-greyscale-8" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-greyscale-9" title="§ 11.3.2.1 cHRM Primary chromaticities and white point">§ 11.3.2.1 cHRM Primary chromaticities and white point</a> </li><li> <a href="#ref-for-dfn-greyscale-10" title="§ 11.3.2.3 iCCP Embedded ICC profile">§ 11.3.2.3 iCCP Embedded ICC profile</a> </li><li> <a href="#ref-for-dfn-greyscale-11" title="§ 11.3.4.1 bKGD Background color">§ 11.3.4.1 bKGD Background color</a> </li><li> <a href="#ref-for-dfn-greyscale-12" title="§ 11.3.4.4 sPLT Suggested palette">§ 11.3.4.4 sPLT Suggested palette</a> </li><li> <a href="#ref-for-dfn-greyscale-13" title="§ 12.5 Suggested palettes">§ 12.5 Suggested palettes</a> </li><li> <a href="#ref-for-dfn-greyscale-14" title="§ 12.7 Filter selection">§ 12.7 Filter selection</a> <a href="#ref-for-dfn-greyscale-15" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-greyscale-16" title="§ 13.11 Truecolor image handling">§ 13.11 Truecolor image handling</a> </li><li> <a href="#ref-for-dfn-greyscale-17" title="§ 13.16 Alpha channel processing">§ 13.16 Alpha channel processing</a> </li><li> <a href="#ref-for-dfn-greyscale-18" title="§ 15.3.3 Conformance of PNG decoders">§ 15.3.3 Conformance of PNG decoders</a> <a href="#ref-for-dfn-greyscale-19" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3greyscale" aria-label="Links in this document to definition: grey sample"> <span class="caret"></span> <div> <a class="self-link" href="#3greyscale" aria-label="Permalink for definition: grey sample. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3greyscale-1" title="§ 4.5 PNG image">§ 4.5 PNG image</a> <a href="#ref-for-3greyscale-2" title="Reference 2">(2)</a> <a href="#ref-for-3greyscale-3" title="Reference 3">(3)</a> <a href="#ref-for-3greyscale-4" title="Reference 4">(4)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3passExtraction" aria-label="Links in this document to definition: Pass extraction"> <span class="caret"></span> <div> <a class="self-link" href="#3passExtraction" aria-label="Permalink for definition: Pass extraction. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3passExtraction-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3reducedImage" aria-label="Links in this document to definition: reduced images"> <span class="caret"></span> <div> <a class="self-link" href="#3reducedImage" aria-label="Permalink for definition: reduced images. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3reducedImage-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3ancillaryChunk" aria-label="Links in this document to definition: ancillary chunk"> <span class="caret"></span> <div> <a class="self-link" href="#3ancillaryChunk" aria-label="Permalink for definition: ancillary chunk. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li>Not referenced in this document.</li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-output-buffer" aria-label="Links in this document to definition: output buffer"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-output-buffer" aria-label="Permalink for definition: output buffer. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-output-buffer-1" title="§ 4.9.1 Structure">§ 4.9.1 Structure</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-canvas" aria-label="Links in this document to definition: canvas"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-canvas" aria-label="Permalink for definition: canvas. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-canvas-1" title="§ 4.9.3 Output buffer">§ 4.9.3 Output buffer</a> <a href="#ref-for-dfn-canvas-2" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-dfn-canvas-3" title="§ 11.3.6.3 fdAT Frame Data Chunk">§ 11.3.6.3 fdAT Frame Data Chunk</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3PNGdatastream" aria-label="Links in this document to definition: PNG datastream"> <span class="caret"></span> <div> <a class="self-link" href="#3PNGdatastream" aria-label="Permalink for definition: PNG datastream. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3PNGdatastream-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> <a href="#ref-for-3PNGdatastream-2" title="Reference 2">(2)</a> <a href="#ref-for-3PNGdatastream-3" title="Reference 3">(3)</a> <a href="#ref-for-3PNGdatastream-4" title="Reference 4">(4)</a> </li><li> <a href="#ref-for-3PNGdatastream-5" title="§ 4.2 Images">§ 4.2 Images</a> <a href="#ref-for-3PNGdatastream-6" title="Reference 2">(2)</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3chunk" aria-label="Links in this document to definition: chunk"> <span class="caret"></span> <div> <a class="self-link" href="#3chunk" aria-label="Permalink for definition: chunk. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3chunk-1" title="§ 3. Terms, definitions, and abbreviated terms">§ 3. Terms, definitions, and abbreviated terms</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-private-field-values" aria-label="Links in this document to definition: private field values"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-private-field-values" aria-label="Permalink for definition: private field values. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-private-field-values-1" title="§ 4.11 Extensions">§ 4.11 Extensions</a> </li><li> <a href="#ref-for-dfn-private-field-values-2" title="§ 5.8 Private field values">§ 5.8 Private field values</a> <a href="#ref-for-dfn-private-field-values-3" title="Reference 2">(2)</a> <a href="#ref-for-dfn-private-field-values-4" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-dfn-private-field-values-5" title="§ 15.3.2 Conformance of PNG encoders">§ 15.3.2 Conformance of PNG encoders</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3colourType" aria-label="Links in this document to definition: color type"> <span class="caret"></span> <div> <a class="self-link" href="#3colourType" aria-label="Permalink for definition: color type. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3colourType-1" title="§ 5.8 Private field values">§ 5.8 Private field values</a> </li><li> <a href="#colorType" title="§ 6.1 Color types and values">§ 6.1 Color types and values</a> <a href="#ref-for-3colourType-3" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3colourType-4" title="§ 7.2 Scanlines">§ 7.2 Scanlines</a> <a href="#ref-for-3colourType-5" title="Reference 2">(2)</a> <a href="#ref-for-3colourType-6" title="Reference 3">(3)</a> <a href="#ref-for-3colourType-7" title="Reference 4">(4)</a> </li><li> <a href="#ref-for-3colourType-8" title="§ 9.2 Filter types for filter method 0">§ 9.2 Filter types for filter method 0</a> </li><li> <a href="#ref-for-3colourType-9" title="§ 11.2.1 IHDR Image header">§ 11.2.1 IHDR Image header</a> <a href="#ref-for-3colourType-10" title="Reference 2">(2)</a> <a href="#ref-for-3colourType-11" title="Reference 3">(3)</a> <a href="#ref-for-3colourType-12" title="Reference 4">(4)</a> <a href="#ref-for-3colourType-13" title="Reference 5">(5)</a> </li><li> <a href="#ref-for-3colourType-14" title="§ 11.2.2 PLTE Palette">§ 11.2.2 PLTE Palette</a> <a href="#ref-for-3colourType-15" title="Reference 2">(2)</a> <a href="#ref-for-3colourType-16" title="Reference 3">(3)</a> <a href="#ref-for-3colourType-17" title="Reference 4">(4)</a> <a href="#ref-for-3colourType-18" title="Reference 5">(5)</a> </li><li> <a href="#ref-for-3colourType-19" title="§ 11.3.1.1 tRNS Transparency">§ 11.3.1.1 tRNS Transparency</a> <a href="#ref-for-3colourType-20" title="Reference 2">(2)</a> <a href="#ref-for-3colourType-21" title="Reference 3">(3)</a> <a href="#ref-for-3colourType-22" title="Reference 4">(4)</a> <a href="#ref-for-3colourType-23" title="Reference 5">(5)</a> <a href="#ref-for-3colourType-24" title="Reference 6">(6)</a> </li><li> <a href="#ref-for-3colourType-25" title="§ 11.3.2.3 iCCP Embedded ICC profile">§ 11.3.2.3 iCCP Embedded ICC profile</a> <a href="#ref-for-3colourType-26" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3colourType-27" title="§ 11.3.2.4 sBIT Significant bits">§ 11.3.2.4 sBIT Significant bits</a> </li><li> <a href="#ref-for-3colourType-28" title="§ 11.3.4.1 bKGD Background color">§ 11.3.4.1 bKGD Background color</a> <a href="#ref-for-3colourType-29" title="Reference 2">(2)</a> <a href="#ref-for-3colourType-30" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-3colourType-31" title="§ 11.3.4.4 sPLT Suggested palette">§ 11.3.4.4 sPLT Suggested palette</a> </li><li> <a href="#ref-for-3colourType-32" title="§ 11.3.6.3 fdAT Frame Data Chunk">§ 11.3.6.3 fdAT Frame Data Chunk</a> </li><li> <a href="#ref-for-3colourType-33" title="§ 12.5 Suggested palettes">§ 12.5 Suggested palettes</a> <a href="#ref-for-3colourType-34" title="Reference 2">(2)</a> <a href="#ref-for-3colourType-35" title="Reference 3">(3)</a> <a href="#ref-for-3colourType-36" title="Reference 4">(4)</a> <a href="#ref-for-3colourType-37" title="Reference 5">(5)</a> <a href="#ref-for-3colourType-38" title="Reference 6">(6)</a> </li><li> <a href="#ref-for-3colourType-39" title="§ 12.7 Filter selection">§ 12.7 Filter selection</a> </li><li> <a href="#ref-for-3colourType-40" title="§ Introduction">§ Introduction</a> </li><li> <a href="#ref-for-3colourType-41" title="§ 13.17 Histogram and suggested palette usage">§ 13.17 Histogram and suggested palette usage</a> </li><li> <a href="#ref-for-3colourType-42" title="§ 15.3.3 Conformance of PNG decoders">§ 15.3.3 Conformance of PNG decoders</a> <a href="#ref-for-3colourType-43" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3colourType-44" title="§ 15.3.4 Conformance of PNG editors">§ 15.3.4 Conformance of PNG editors</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3filter" aria-label="Links in this document to definition: filter method"> <span class="caret"></span> <div> <a class="self-link" href="#3filter" aria-label="Permalink for definition: filter method. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-3filter-1" title="§ 7.3 Filtering">§ 7.3 Filtering</a> <a href="#ref-for-3filter-2" title="Reference 2">(2)</a> </li><li> <a href="#ref-for-3filter-3" title="§ 9.1 Filter methods and filter types">§ 9.1 Filter methods and filter types</a> <a href="#ref-for-3filter-4" title="Reference 2">(2)</a> <a href="#ref-for-3filter-5" title="Reference 3">(3)</a> <a href="#ref-for-3filter-6" title="Reference 4">(4)</a> <a href="#ref-for-3filter-7" title="Reference 5">(5)</a> </li><li> <a href="#ref-for-3filter-8" title="§ 9.2 Filter types for filter method 0">§ 9.2 Filter types for filter method 0</a> <a href="#ref-for-3filter-9" title="Reference 2">(2)</a> <a href="#ref-for-3filter-10" title="Reference 3">(3)</a> </li><li> <a href="#ref-for-3filter-11" title="§ 11.2.1 IHDR Image header">§ 11.2.1 IHDR Image header</a> </li><li> <a href="#ref-for-3filter-12" title="§ 11.3.6.3 fdAT Frame Data Chunk">§ 11.3.6.3 fdAT Frame Data Chunk</a> </li><li> <a href="#ref-for-3filter-13" title="§ Introduction">§ Introduction</a> </li><li> <a href="#ref-for-3filter-14" title="§ 15.3.3 Conformance of PNG decoders">§ 15.3.3 Conformance of PNG decoders</a> </li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-3criticalChunk" aria-label="Links in this document to definition: critical chunk"> <span class="caret"></span> <div> <a class="self-link" href="#3criticalChunk" aria-label="Permalink for definition: critical chunk. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li>Not referenced in this document.</li> </ul> </div><div class="dfn-panel" hidden="" role="dialog" aria-modal="true" id="dfn-panel-for-dfn-gamma-encoding" aria-label="Links in this document to definition: gamma encoding"> <span class="caret"></span> <div> <a class="self-link" href="#dfn-gamma-encoding" aria-label="Permalink for definition: gamma encoding. Activate to close this dialog.">Permalink</a> </div> <p><b>Referenced in:</b></p> <ul> <li> <a href="#ref-for-dfn-gamma-encoding-1" title="§ 12.1 Encoder gamma handling">§ 12.1 Encoder gamma handling</a> <a href="#ref-for-dfn-gamma-encoding-2" title="Reference 2">(2)</a> <a href="#ref-for-dfn-gamma-encoding-3" title="Reference 3">(3)</a> <a href="#ref-for-dfn-gamma-encoding-4" title="Reference 4">(4)</a> </li> </ul> </div><script id="respec-dfn-panel">(() => { // @ts-check if (document.respec) { document.respec.ready.then(setupPanel); } else { setupPanel(); } function setupPanel() { const listener = panelListener(); document.body.addEventListener("keydown", listener); document.body.addEventListener("click", listener); } function panelListener() { /** @type {HTMLElement} */ let panel = null; return event => { const { target, type } = event; if (!(target instanceof HTMLElement)) return; // For keys, we only care about Enter key to activate the panel // otherwise it's activated via a click. if (type === "keydown" && event.key !== "Enter") return; const action = deriveAction(event); switch (action) { case "show": { hidePanel(panel); /** @type {HTMLElement} */ const dfn = target.closest("dfn, .index-term"); panel = document.getElementById(`dfn-panel-for-${dfn.id}`); const coords = deriveCoordinates(event); displayPanel(dfn, panel, coords); break; } case "dock": { panel.style.left = null; panel.style.top = null; panel.classList.add("docked"); break; } case "hide": { hidePanel(panel); panel = null; break; } } }; } /** * @param {MouseEvent|KeyboardEvent} event */ function deriveCoordinates(event) { const target = /** @type HTMLElement */ (event.target); // We prevent synthetic AT clicks from putting // the dialog in a weird place. The AT events sometimes // lack coordinates, so they have clientX/Y = 0 const rect = target.getBoundingClientRect(); if ( event instanceof MouseEvent && event.clientX >= rect.left && event.clientY >= rect.top ) { // The event probably happened inside the bounding rect... return { x: event.clientX, y: event.clientY }; } // Offset to the middle of the element const x = rect.x + rect.width / 2; // Placed at the bottom of the element const y = rect.y + rect.height; return { x, y }; } /** * @param {Event} event */ function deriveAction(event) { const target = /** @type {HTMLElement} */ (event.target); const hitALink = !!target.closest("a"); if (target.closest("dfn:not([data-cite]), .index-term")) { return hitALink ? "none" : "show"; } if (target.closest(".dfn-panel")) { if (hitALink) { return target.classList.contains("self-link") ? "hide" : "dock"; } const panel = target.closest(".dfn-panel"); return panel.classList.contains("docked") ? "hide" : "none"; } if (document.querySelector(".dfn-panel:not([hidden])")) { return "hide"; } return "none"; } /** * @param {HTMLElement} dfn * @param {HTMLElement} panel * @param {{ x: number, y: number }} clickPosition */ function displayPanel(dfn, panel, { x, y }) { panel.hidden = false; // distance (px) between edge of panel and the pointing triangle (caret) const MARGIN = 20; const dfnRects = dfn.getClientRects(); // Find the `top` offset when the `dfn` can be spread across multiple lines let closestTop = 0; let minDiff = Infinity; for (const rect of dfnRects) { const { top, bottom } = rect; const diffFromClickY = Math.abs((top + bottom) / 2 - y); if (diffFromClickY < minDiff) { minDiff = diffFromClickY; closestTop = top; } } const top = window.scrollY + closestTop + dfnRects[0].height; const left = x - MARGIN; panel.style.left = `${left}px`; panel.style.top = `${top}px`; // Find if the panel is flowing out of the window const panelRect = panel.getBoundingClientRect(); const SCREEN_WIDTH = Math.min(window.innerWidth, window.screen.width); if (panelRect.right > SCREEN_WIDTH) { const newLeft = Math.max(MARGIN, x + MARGIN - panelRect.width); const newCaretOffset = left - newLeft; panel.style.left = `${newLeft}px`; /** @type {HTMLElement} */ const caret = panel.querySelector(".caret"); caret.style.left = `${newCaretOffset}px`; } // As it's a dialog, we trap focus. // TODO: when <dialog> becomes a implemented, we should really // use that. trapFocus(panel, dfn); } /** * @param {HTMLElement} panel * @param {HTMLElement} dfn * @returns */ function trapFocus(panel, dfn) { /** @type NodeListOf<HTMLAnchorElement> elements */ const anchors = panel.querySelectorAll("a[href]"); // No need to trap focus if (!anchors.length) return; // Move focus to first anchor element const first = anchors.item(0); first.focus(); const trapListener = createTrapListener(anchors, panel, dfn); panel.addEventListener("keydown", trapListener); // Hiding the panel releases the trap const mo = new MutationObserver(records => { const [record] = records; const target = /** @type HTMLElement */ (record.target); if (target.hidden) { panel.removeEventListener("keydown", trapListener); mo.disconnect(); } }); mo.observe(panel, { attributes: true, attributeFilter: ["hidden"] }); } /** * * @param {NodeListOf<HTMLAnchorElement>} anchors * @param {HTMLElement} panel * @param {HTMLElement} dfn * @returns */ function createTrapListener(anchors, panel, dfn) { const lastIndex = anchors.length - 1; let currentIndex = 0; return event => { switch (event.key) { // Hitting "Tab" traps us in a nice loop around elements. case "Tab": { event.preventDefault(); currentIndex += event.shiftKey ? -1 : +1; if (currentIndex < 0) { currentIndex = lastIndex; } else if (currentIndex > lastIndex) { currentIndex = 0; } anchors.item(currentIndex).focus(); break; } // Hitting "Enter" on an anchor releases the trap. case "Enter": hidePanel(panel); break; // Hitting "Escape" returns focus to dfn. case "Escape": hidePanel(panel); dfn.focus(); return; } }; } /** @param {HTMLElement} panel */ function hidePanel(panel) { if (!panel) return; panel.hidden = true; panel.classList.remove("docked"); } })()</script><script src="https://www.w3.org/scripts/TR/2021/fixup.js"></script></body></html>