#!/bin/csh -f # Kenneth Kang # 11-17-99 # Makes an image map index for a set of JPEGs. set size = 96 set grid = 100 set cols = 6 set color = "white" set col = 0 set row = 0 set tmp = /tmp/htmlindex.$$ set thumbnail = $tmp\.thumbnail.pnm set cell = $tmp\.cell.pnm set cur = $tmp\.cur.pnm set out = $tmp\.out.pnm set target = "$1" shift echo '' foreach jpeg ( $argv ) rm -f $thumbnail $cell djpeg $jpeg | \ pnmscale -xysize $size $size > $thumbnail set dim = `pnmfile $thumbnail` @ x = ( $grid - $dim[4] ) / 2 @ y = ( $grid - $dim[6] ) / 2 ppmmake $color $grid $grid | \ pnmpaste -replace $thumbnail $x $y > $cell # Append a row if ( $col == $cols ) then @ col = 0 @ row++ if ( -r $out ) then pnmcat -tb $out $cur > $tmp mv $tmp $out rm -f $cur else mv $cur $out endif endif # Generate HTML Tag @ x1 = $col * $grid @ y1 = $row * $grid @ x2 = $x1 + $grid - 1 @ y2 = $y1 + $grid - 1 echo -n ' ' echo "" # Append a thumbnail if ( -r $cur) then pnmcat -lr $cur $cell > $tmp mv $tmp $cur else mv $cell $cur endif @ col++ end echo '' echo -n 'Picture Index' echo "" # Append last row (if any) if ( -r $cur && -r $out ) then pnmcat -tb -jleft $out $cur > $tmp mv $tmp $out else mv $cur $out endif cjpeg $out > $target # Clean up foreach file ( $tmp $thumbnail $cell $cur $out ) if ( -r $file ) rm -f $file end