Unix Programming - The Importance of Being Textual - Case Study: The PNG Graphics File Format
PNG (Portable Network Graphics) is a file format for bitmap
graphics. It is like GIF,
and unlike JPEG, in that it uses lossless compression and is optimized
for applications such as line art and icons rather than photographic
images. Documentation and open-source reference libraries of high
quality are available at the Portable Network Graphics
website.
PNG is an excellent example of a thoughtfully designed binary
format. A binary format is appropriate since graphics files may
contain very large amounts of data, such that storage size and
Internet download time would go up significantly if the pixel data
were stored textually. Transaction economy was the prime
consideration, with
transparency
sacrificed.[53] The designers were, however, careful about
interoperability; PNG specifies byte orders, integer word lengths,
endianness, and (lack of) padding between fields.
A PNG file consists of a sequence of chunks, each in a
self-describing format beginning with the chunk type name and the
chunk length. Because of this organization, PNG does not need a
release number. New chunk types can be added at any time; the case of
the first letter in the chunk
type name informs PNG-using software whether or not each chunk can be
safely ignored.
The PNG file header also repays study. It has been
cleverly designed to make various common kinds of file corruption
(e.g., by 7-bit transmission links, or mangling of CR and LF
characters) easy to detect.
The PNG standard is precise, comprehensive, and well written. It
could serve as a model for how to write file format standards.
[an error occurred while processing this directive]
|