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