Version 7 of Reading JPEG comments

Updated 2003-12-19 21:56:54

proc read_jpg_comments {file} {

    set fh [open $file r]
    fconfigure $fh -encoding binary -translation binary -eofchar {}
    if {[read $fh 2] != "\xFF\xD8"} { close $fh; return }
    set comments {}

    while {[read $fh 1] == "\xFF"} {
        binary scan [read $fh 3] aS type len
        set pos [tell $fh]
        if {$type == "\xFE"} {
            lappend comments [read $fh [expr $len - 2]]
        }
        seek $fh [expr {$pos + $len - 2}] start
    }
    return $comments
 }

returns a list containing all the comments found in file

--AF 19-12-03

TV Nice, works. Would you happen to know how to read other information, for instance I can use a camera which nicely records picture data and time and some cam settings, which explorer nicely pops up. It would be nice to be able to read that, too.

AF For that I think you need to see EXIF


Category Graphics