#!/bin/csh # # Generate a html file with the GIFs generated with ImageMagik's convert command # on the fly. # syntax: # gif2html [ ... ] # Description: # A basic HTML file is written on standard output that assembles all the # FIG or JPEG files that are (i) listed in the command line and (ii) actually # the UNXI file system in a "directory" type manner. That means the HTML file # places smaller iconic versions of the files, 4 in a row, onto a single page # such that clicking on the iconic versions yields the "full-size" originals. # Caution: # Creates foo_s.gif for each file foo.gif given in the command line (generates files # names automatically from *.gif by replacing the "dot" with a "_sdot"). # This may overwrite/delete original contents in exceptional cases. # Running the same program multiple times in the same directory without # manual deletion of the iconic files will create cascaded versions of # icons of icons of icons etc, which is probably not what you want. # Requirements: # A command 'convert' must be applicable to convert the files on the # command line to the iconic GIF files, for example from the ImageMagik package.. # Bugs: # Yes, this is a hack, which shall cause pain, distraction and wars. # example: # ls -l *.gif # gif2html *.gif *.jpeg > mypics.html 2>/dev/null # netscape mypics.html # Richard J Mathar, 9 Feb 2001 # number of pictures per image line set pixperline=4 # pixel size for icon images set pixwidth=150 # HTML header echo '' echo '' echo '' echo '' echo '' echo \ echo '' echo '' echo '' echo '' echo '' echo '' # green text, black background echo '' echo '' echo '' repeat $pixperline echo "" echo '' echo echo '' set col=0 foreach gif ( $argv[1-] ) # filename of icon image by adding _s to the basename and switching from jpeg to gif set smallgif=`basename $gif .gif` set smallgif=`basename $smallgif .jpeg` set smallgif=${smallgif}.gif set smallgif=`echo $smallgif | sed 's/\./_s\./'` # icon image with maximum edge length of 100, maintaining side length ratio convert -geometry ${pixwidth}x${pixwidth} $gif $smallgif # fold -b -w 6 $smallgif | head -1 should read 'GIF89a' # first 6 bytes are GIF89a, next two are width, next two are height # swab bytes 7-8 and 9-10 because they are wrong endian # Using |& and only the first two bytes seen by od deletes the '1+0 records in, 0+1 records out' messages # by dd (there seems not to be any option to do this) set width=`dd ibs=2 skip=3 count=1 conv=swab if=$smallgif |& od -d -A n -N 2` set height=`dd ibs=2 skip=4 count=1 conv=swab if=$smallgif |& od -d -A n -N 2` # a method to delete leading zeros from the number representations left over by od @ width= $width + 0 @ height= $height + 0 echo '' @ col++ if ( $col == 4 ) then echo '' echo echo '' set col=0 endif end echo '' echo echo '
' '
' set bytes=`ls -g $gif | awk '{printf "%.0f",$4/1000}'` echo $gif '(' $bytes 'kbytes)
' #HTML footer echo '' echo ''