#!/bin/csh # # Reads an eps file(s) created by matlab, possibly with many # frames, and creates html/gif from it. See "man page" at the # end of this file. # # Required utilities # ------------------ set CONVERT = /usr/bin/convert # ImageMagick convert # No args # -------- if ( $#argv < 1 ) goto usage # Parse command line arguments # ---------------------------- set title = 'EPS HTML Translator' set dirn = " " set notes = " " set verb = 1 # verbose mode set contents = 0 foreach token ( $argv ) if ( "$token" == "-p" ) then set mode = 'Portrait' # obsolete, no effect shift endif if ( "$token" == "-q" ) then set verb = 0 shift endif if ( "$token" == "-c" ) then set contents = 1 shift endif if ( "$token" == "-t" ) then shift set title = ( $1 ) shift endif if ( "$token" == "-d" ) then shift if ( $#argv < 1 ) goto usage set dirn = $1 shift endif if ( "$token" == "-n" ) then shift if ( $#argv < 1 ) goto usage set notes = $1 shift if ( !(-e $notes) ) then echo "epshtml: cannot open notes file $notes" exit 1 endif endif end # Make sure all eps files are there # -------------------------------- if ( $#argv < 1 ) goto usage foreach epsfilen ( $argv ) if ( !(-e $epsfilen) ) then echo "epshtml: cannot find file $epsfilen" exit 1 endif endif if ( $verb ) echo " " if ( $verb ) echo "EPS to HTML starting . . ." # Create or reuse directory for HTML/GIF files, # -------------------------------------------- if ( x$dirn == x ) then set basen = `basename $1` set dirn = $basen:r endif if ( -d $dirn ) then if ( $verb ) echo " o Re-using directory $dirn/ for html/gif files" touch $dirn/index.html if ( $status ) then echo "epshtml: cannot write to directory $dirn" exit 1 endif else if ( $verb ) echo " o Creating directory $dirn/ for html/gif files" mkdir $dirn if ( $status ) then echo "epshtml: cannot create directory $dirn" exit 1 endif endif # Create HTML header # ------------------ set htmlfn = $dirn/index.html if ( -e $htmlfn ) /bin/rm -r $htmlfn echo "" > $htmlfn echo " $title " >> $htmlfn echo "> $htmlfn echo "LINK=#0000FF VLINK=#006030>" >> $htmlfn echo "

" >> $htmlfn echo $title >> $htmlfn echo "

" >> $htmlfn if ( x$notes != x ) then echo "

" >> $htmlfn cat $notes >> $htmlfn echo "

" >> $htmlfn endif echo "

" >> $htmlfn echo "Click on the images below to enlarge them" >> $htmlfn echo "
" >> $htmlfn if ( $contents ) echo "


" >> $htmlfn # Loop over eps files # ------------------ foreach epsfilen ( $argv ) if ( !(-e $epsfilen) ) then echo "epshtml: cannot find file $epsfilen exit 1 endif set basen = $epsfilen:r # land/port mode vary for each file # --------------------------------- set mode = 'Portrait' if ( $status ) goto cleanup if ( "$mode" == "Landscape" ) then set rotate = '-rotate 90' else set rotate = ' ' endif # Make postscript/gif in a pipe # ----------------------------- if ( $verb ) echo " o Creating GIF images from $mode metafile ${epsfilen}" set tbasen = $dirn/$basen.tmp echo "convert from "$epsfilen "to "$tbasen":" $CONVERT +adjoin -density 60x60 $rotate eps:$epsfilen gif:$tbasen >& /dev/null if ( $status ) goto cleanup foreach tmp ( $tbasen* ) set fno = $tmp:e if ( "$fno" != "tmp" ) then @ fno = 100 + $fno set gif = $dirn/${basen}_p$fno.gif else set gif = $dirn/${basen}_p100.gif endif mv $tmp $gif # Rename GIF files if ( $verb ) echo " o Created GIF file $gif " end # Make thumbnail sketches (Note: could create sketches from GIF) # -------------------------------------------------------------- if ( ! $contents ) then if ( $verb ) echo " o Creating thumbnail sketches from $mode metafile ${epsfilen}" set tbasen = $dirn/$basen.tmp $CONVERT +adjoin -density 16x16 $rotate eps:$epsfilen gif:$tbasen >& /dev/null if ( $status ) goto cleanup foreach tmp ( $tbasen* ) set fno = $tmp:e if ( "$fno" != "tmp" ) then @ fno = 100 + $fno set gif = $dirn/${basen}_t$fno.gif else set gif = $dirn/${basen}_t100.gif endif mv $tmp $gif # Rename GIF files if ( $verb ) echo " o Created GIF file $gif " end endif # Add HTML lines for these files # ------------------------------ echo " " >> $htmlfn echo "

Images from file " >> $htmlfn echo "$epsfilen " >> $htmlfn if ( $contents ) then echo ": " >> $htmlfn else echo "


" >> $htmlfn endif set fno = 1 foreach gifpage ( $dirn/${basen}_p*.gif ) set gifbase = `basename $gifpage` set thumb = `echo $gifbase | sed -e 's/_p/_t/g'` if ( $contents ) then echo " | $fno" >> $htmlfn @ fno++ else echo "" >> $htmlfn endif end if ( $contents ) then echo "|

" >> $htmlfn else echo "


" >> $htmlfn endif end # Records when and by whom document was created # --------------------------------------------- set usern = `whoami` echo \$1 == \"$usern\" \{print \$5\} >! $tmp set whom = `awk -F: -f $tmp < /etc/passwd|awk -F, '{print $1}'` if ( $#whom < 1 ) set whom = $usern set when = `date` # Now clean-up mess # ----------------- # /bin/rm -r $tmp $dirn/*.ps if ( $verb ) echo "EPS to HTML exited normally" if ( $verb ) echo " " exit 0 cleanup: # /bin/rm -r $tmp $dirn/*.ps if ( $verb ) echo "EPS to HTML exited abnormally" exit 1 usage: cat << ---//--- NAME epsHTML - EPS HTML Translator SYNOPSIS epshtml [-q] [-c] [-d path] [-n file] [-t title] eps_file(s) DESCRIPTION This utility creates a HTML document with images from eps files. Clickable thumbnail sketches are produced for each of the images, with higher resolution images accessible with a mouse click. This utility, together with your favorite web browser, can be used as a starting point for building customized web pages. For the heavy duty conversion work this utility relies on the ImageMagick 'convert' utility. This packages must be installed on your system. epsHTML is nothing more than a C-Shell script driving the package. OPTIONS -d path directory for output HTML/GIF files, default is to use the base name of the first eps file, i.e., if the file name is 'myfile.eps', the directory will be 'myfile' -n file specify ASCII file with notes to be appended to output HTML -q quiet mode (default is verbose) -c include a text "table of contents" instead of thumbnail sketches (this is faster) -t title title for output HTML document, the default is 'epsHTML - eps HTML Translator' EXAMPLE epshtml myfile.eps netscape myfile/index.html ---//--- exit 1