#!/usr/local/bin/tclsh8.1
## Modified from a script by Mark Handley
## This one only uses two images, the larger one, and the thumbnail.

set files [glob *.jpg]
set lores [open "index.html" "w"]
puts $lores "<HEAD><TITLE>Images</TITLE></HEAD>
<BODY bgcolor=\"#000000\" text=\"#ffffff\" link=\"#0000ff\" vlink=\"#b20000\">"

foreach file $files {
    set shortfile [lindex [split $file "."] 0]
    puts "converting $file..."
    set output [exec identify $file]
    set size [lindex $output 1]
    #puts "size $size"
    set size1 [split $size x]
    set width [lindex $size1 0]
    set height [lindex $size1 1]
    #puts "height $height width $width"
    if {$height > $width} {
	exec convert -size 120x160 $file lores-$file
    } else {
	exec convert -size 160x120 $file lores-$file
    }
    puts $lores "<a href=$file><img src=lores-$file height=120></a>"
    puts "done"
}

puts $lores "</BODY>"
