为什么 PNG 块被这样命名?

Why were PNG chunks named like that?

我研究了 PNG 结构以开发一些关于它的东西。我发现了一些有趣的东西。

关键 PNG 块的名称(IHDRPLTEIDATIENDPLTE) 都是大写的。 ancillary PNG chunks(bKGD, cHRM, gAMA, hIST, 名称中至少有一个小写字符iCCPiTXtpHYssBITsPLTsRGBsTERtEXttIMEtRNSzTXt、等等)。

我很好奇。他们标准化的时候有命名规则吗?

根据Jongware,答案是这样的: https://www.w3.org/TR/PNG/#5Chunk-naming-conventions

5.4 Chunk naming conventions

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). However, 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.

The property bits are an inherent part of the chunk type, and hence are fixed for any chunk type. Thus, CHNK and cHNk would be unrelated chunk types, not the same chunk with different properties.

The semantics of the property bits are defined in Table 5.2.

Table 5.2 — Semantics of property bits

Ancillary bit: first byte

0 (uppercase) = critical, 1 (lowercase) = ancillary.

Critical chunks are necessary for successful display of the contents of the datastream, for example the image header chunk(IHDR). 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. Ancillary chunks are not strictly necessary in order to meaningfully display the contents of the datastream, for example the time chunk(tIME). 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.

私有位:第二个字节

0(大写)= public,1(小写)= 私有。

A public chunk is one that is defined in this International Standard or is registered in the list of PNG special-purpose public chunk types maintained by the Registration Authority (see 4.9 Extension and registration). Applications can also define private (unregistered) chunk types for their own purposes. The names of private chunks have a lowercase second letter, while public chunks will always be assigned names with uppercase second letters. Decoders do not need to test the private-chunk property bit, since it has no functional significance; it is simply an administrative convenience to ensure that public and private chunk names will not conflict. See clause 14: Editors and extensions and 12.10.2: Use of private chunks.

保留位:第三个字节

0(大写)在此版本的 PNG 中。如果保留位为 1,则数据流不符合此版本的 PNG。

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.

安全复制位:第四字节

0(大写)= 复制不安全,1(小写)= 复制安全。

This property bit is not of interest to pure decoders, but it is needed by PNG editors. This bit defines the proper handling of unrecognized chunks in a datastream that is being modified. Rules for PNG editors are discussed further in 14.2: Behaviour of PNG editors.