64d63
<     variable thumbnail
69,71c68
<     if {$debug} {
<       puts $str
<     }
---
>     if {$debug} {puts $str}
78,79c75
< proc exif::analyze {file {thumb {}}} {
<     set stream [open $file]
---
> proc exif::analyze {stream} {
81,86d76
<     variable thumbnail
<     set thumbnail {}
<     if {$thumb != {}} {
<         #set thumbnail [file rootname $file]_THM[file extension $file]
<         set thumbnail $thumb
<     }
108d97
<           debug "read [expr $size - 2] bytes of data"
129,130d117
<     close $stream
< 
194d180
<           debug "==CALLING exifSubIFD=="
197c183
<             debug "Unrecognized entry: Tag=$tag, value=$value"
---
>             debug "Unrecognised entry: Tag=$tag, value=$value"
202,215d187
<     array set thumb_result [exifSubIFD $data $offset]
<     variable thumbnail
<     if {$thumbnail != {}} {
<       set jpg [string range $data $thumb_result(JpegIFOffset) [expr $thumb_result(JpegIFOffset) + $thumb_result(JpegIFByteCount) - 1]]
< 
<         set to [open $thumbnail w]
<         fconfigure $to -translation binary -encoding binary
<       puts $to $jpg
<         close $to
< 
<         #can be used (with a JPG-aware TK) to add the image to the result array
<       #set result(THUMB) [image create photo -file $thumbnail]
<     }
< 
339,393d310
<             } elseif {$tag == 0xA401} {
<               #TJE
<               set result(SensingMethod) "normal"
<                 if {$value == 1} {set result(SensingMethod) "custom"}
<             } elseif {$tag == 0xA402} {
<               #TJE
<                 set result(ExposureMode) "auto"
<                 if {$value == 1} {set result(ExposureMode) "manual"}
<                 if {$value == 2} {set result(ExposureMode) "auto bracket"}
<             } elseif {$tag == 0xA403} {
<               #TJE
<                 set result(WhiteBalance) "auto"
<                 if {$value == 1} {set result(WhiteBalance) "manual"}
<             } elseif {$tag == 0xA404} {
<                 # digital zoom not used if number is zero
<               set result(DigitalZoomRatio) "not used"
<                 if {$value != 0} {set result(DigitalZoomRatio) $value}
<             } elseif {$tag == 0xA405} {
<               set result(FocalLengthIn35mmFilm) "unknown"
<                 if {$value != 0} {set result(FocalLengthIn35mmFilm) $value}
<             } elseif {$tag == 0xA406} {
<                 set result(SceneCaptureType) "Standard"
<                 if {$value == 1} {set result(SceneCaptureType) "Landscape"} 
<                 if {$value == 2} {set result(SceneCaptureType) "Portrait"}
<                 if {$value == 3} {set result(SceneCaptureType) "Night scene"}
<             } elseif {$tag == 0xA407} {
<                 set result(GainControl) "none"
<                 if {$value == 1} {set result(GainControl) "Low gain up"} 
<                 if {$value == 2} {set result(GainControl) "High gain up"}
<                 if {$value == 3} {set result(GainControl) "Low gain down"}
<                 if {$value == 4} {set result(GainControl) "High gain down"}
<             } elseif {$tag == 0x0103} {
<               #TJE
<               set result(Compression) "unknown"
<               if {$value == 1} {set result(Compression) "none"}
<               if {$value == 6} {set result(Compression) "JPEG"}
<             } elseif {$tag == 0x011A} {
<               #TJE
<               set result(XResolution) $value
<             } elseif {$tag == 0x011B} {
<               #TJE
<               set result(YResolution) $value
<             } elseif {$tag == 0x0128} {
<               #TJE
<               set result(ResolutionUnit) "unknown"
<               if {$value == 1} {set result(ResolutionUnit) "inch"}
<               if {$value == 6} {set result(ResolutionUnit) "cm"}
<             } elseif {$tag == 0x0201} {
<               #TJE
<               set result(JpegIFOffset) $value
< debug "offset = $value"
<             } elseif {$tag == 0x0202} {
<               #TJE
<               set result(JpegIFByteCount) $value
< debug "bytecount = $value"
395c312
<                 error "Unrecognized EXIF Tag: $tag (0x[string toupper [format %x $tag]])"
---
>                 error "Unrecognised EXIF Tag: $tag"
630,631c547,548
<                         set v [expr {$field($k) & 0xFF}]
<                         if {$func==1 && $v} {
---
>                         set val [expr {$field($k) & 0xFF}]
>                         if {$func==1 && $val} {
633c550
<                         } elseif {$func==1 && !$v} {
---
>                         } elseif {$func==1 && !$val} {
636c553
<                             set result(Shutter/AE-Lock) [switch $v {
---
>                             set result(Shutter/AE-Lock) [switch $val {
716c633
<                             set result(CameraOwner) $v
---
>                             set result(CameraOwner) $value
718c635
<                             append result(UnknownCustomFunc) "$func=$v "
---
>                             append result(UnknownCustomFunc) "$func=$value "
723c640
<                 debug [format "makerNote: Unrecognized TAG: 0x%x" $tag]
---
>                 debug [format "makerNote: Unrecognised TAG: 0x%x" $tag]
