Version 1 of Reading PNG Timestamps

Updated 2003-12-17 20:55:55

proc read_png_timestamp {file} {

    set fh [open $file r]
    fconfigure $fh -encoding binary -translation binary -eofchar {}
    if {[read $fh 8] != "\x89PNG\r\n\x1a\n"} { close $fh; return }

    while {[set r [read $fh 8]] != ""} {
        binary scan $r Ia4 len type
        set r [read $fh [expr {$len + 4}]]
        if {[string length $r] != ($len + 4)} { close $fh; return }
        if {$type == "tIME"} {
            binary scan $r Sccccc year month day hour minute second
            close $fh
            return [list $year $month $day $hour $minute $second]
        }
    }
    close $fh
    return
 }

--AF Returns a list in the following format: year month day hour minute second


Category Graphics