#!/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 "
" >> $htmlfn cat $notes >> $htmlfn echo "
" >> $htmlfn endif 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 else echo "