Project

General

Profile

Actions

The Metadata in PNG files » History » Revision 6

« Previous | Revision 6/16 (diff) | Next »
Tuan Nhu, 13 Aug 2013 02:32


The Metadata in PNG files

The Portable Network Graphics (PNG) is a raster graphics file format that supports a portable, legally unencumbered, well-compressed, well-specified standard for lossless bitmapped image files.

A PNG always starts with an 8-byte signature: 137 80 78 71 13 10 26 10 (decimal values). The remainder of the file consists a series of chunks beginning with an IHDR chunk and ending with an IEND chunk.

1. Chunks

Each chunk consists of four parts:

Length 4 bytes An unsigned integer giving the number of bytes in the chunk's data field. The length counts only the data field, not itself, the chunk type code, or the CRC. Zero is a valid length. Although encoders and decoders should treat the length as unsigned, its value must not exceed 231-1 bytes.
Chunk type 4 bytes Type codes are restricted to consist of uppercase and lowercase ASCII letters and they are case sensitive.
+ The case of the first letter indicates whether the chunk is critical or not. If the first letter is uppercase, the chunk is critical; if not, the chunk is ancillary. Critical chunks contain information that is necessary to read the file. If a decoder encounters a critical chunk it does not recognize, it must abort reading the file or supply the user with an appropriate warning.
+ The case of the second letter indicates whether the chunk is "public" (either in the specification or the registry of special-purpose public chunks) or "private" (not standardised). Uppercase is public and lowercase is private.
+ The third letter must be uppercase to conform to the PNG specification. It is reserved for future expansion.
+ The case of the fourth letter indicates whether the chunk is safe to copy by editors that do not recognize it.
Chunk data Length bytes The data bytes appropriate to the chunk type, if any. This field can be of zero length.
CRC 4 bytes A CRC (Cyclic Redundancy Check) calculated on the preceding bytes in the chunk, including the chunk type code and chunk data fields, but not including the length field. The CRC is always present, even for chunks containing no data.

The standard chunks:

2. Textual information chunks - the metadata in PNG

Updated by Tuan Nhu over 8 years ago · 6 revisions