Tk Library Source Code

View Ticket
Login
Ticket UUID: 1352422
Title: tcllib jpeg bugs
Type: Bug Version: None
Submitter: nobody Created on: 2005-11-09 18:03:31
Subsystem: jpeg Assigned To: afaupell
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2005-11-10 14:49:33
Resolution: None Closed By: afaupell
    Closed on: 2005-11-10 07:49:33
Description:
2 bugs in tcllib jpeg 0.1 module

1. ::jpeg::isJPEG : the return value is inverted. Here is
the correct code:

proc ::jpeg::isJPEG {file} {
    set is [catch {openJFIF $file} fh]
    catch {close $fh}
    return [expr {! $is}]
}


2. ::jpeg::dimensions : this code needs to find the SOF
marker but only recognizes the SOF marker type byte
of value c0 and misses c1, c2 and c3. The wiki page 
http://wiki.tcl.tk/757 has more details.

Here is the correct code:


proc ::jpeg::dimensions {file} {
    set fh [openJFIF $file]
    set chunks [markers $fh]

    foreach SOFByte {0 1 2 3} {
        set sof [lsearch $chunks "c$SOFByte *"]
        if {$sof != -1} break
    }
    if {$sof == -1} { return -code error "cannot locate sof 
marker" }
    seek $fh [lindex $chunks $sof 1] start
        
    binary scan [read $fh 5] cSS precision height width
    close $fh
    return [list $width $height]
}


Keith Vetter
User Comments: afaupell added on 2005-11-10 14:49:33:
Logged In: YES 
user_id=812825

fixed code to accept c0-3 for SOF. thanks

afaupell added on 2005-11-10 02:49:35:
Logged In: YES 
user_id=812825

bug 1 was fixed on 4/2/05 i suggest upgrading to the latest 
version before submitting a bug report. I will look into #2