The PNG Guide is an eBook based on Greg Roelofs' book, originally published by O'Reilly.



Timestamp (tIME)

  • Status:   PNG Specification
  • Location:   anywhere[85]
  • Multiple:   no

[85] Chunks with no explicit restrictions (``anywhere'') are nonetheless implicitly constrained to come after the PNG signature and IHDR chunk, before the IEND chunk, and not to fall between multiple IDAT chunks.

The timestamp chunk provides a way for the author (or image-editing software) to record the time and date the image was last modified. The chunk contains 7 bytes of data, shown in Table 11-1.

Table 11-1. tIME Chunk

Field Length and Valid Range
Year 2 bytes (0-65,535)
Month 1 byte (1-12)
Day 1 byte (1-31)
Hour 1 byte (0-23)
Minute 1 byte (0-59)
Second 1 byte (0-60)

As this book is being written before the Third Millennium begins, the first thing to notice is that PNG is not merely Y2K-compliant, but also Y2038, Y10K, and pretty much everything else on up through Y65K.[86] In addition, note that the seconds field is permitted to vary between 0 and 60; this allows for leap seconds, of which there have been roughly two dozen since 1972. (There has never been more than one leap second in any given minute, however.)

[86] Presumably humanity will have come up with another image format or two by then.

On a less technical level, why does tIME store the modification time rather than creation time? On the face of it, creation time would seem like a more useful piece of information, and indeed, it is explicitly supported in PNG via the text chunks described later. But whereas modification time is a well-defined quantity--even a computer program can determine whether the image data has been modified--creation time is ambiguous. If a scanned photograph of the Mona Lisa is converted to PNG format, is its creation time the time of image conversion, the time of the original scan, the time the photograph was taken, or even the time the painting was created? The case becomes even muddier if an artist creates a digital work partly based on the scanned image. So creation time is supported via one or more text chunks, which can also describe in precisely what sense the image was created.




Last Update: 2010-Nov-26