"Fossies" - the Fresh Open Source Software Archive

Member "hevea-2.35/imagen" (16 Jan 2021, 2666 Bytes) of package /linux/www/hevea-2.35.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #! /bin/sh
    2 LATEX=latex
    3 DVIPS=dvips
    4 GS=gs
    5 COM=/tmp/imagen-com.$$
    6 RESOLUTION=100 # resolution in dpi
    7 CROP="-trim +repage "
    8 EXTRA=" "
    9 MARGIN="-bordercolor none -border 2 "
   10 TOGIF="-background white -flatten -interlace Plane gif:-"
   11 TOPNG="-interlace Plane -quality 90 png:-"
   12 TOEXT=${TOPNG}
   13 EXT=png
   14 TODIR="."
   15 SVG=false
   16 RM="/bin/rm -f"
   17 
   18 
   19 while true
   20 do
   21     case $1 in
   22      -todir)
   23        shift
   24        TODIR="$1"
   25        mkdir -p ${TODIR} 2> /dev/null || :
   26        ;;
   27      -gif)
   28     TOEXT=${TOGIF}
   29         EXT=gif
   30         ;;
   31      -png)
   32         TOEXT=${TOPNG}
   33         EXT=png
   34         ;;
   35      -pnm)
   36         TOEXT="pnm:-"
   37         EXT=pnm
   38         ;;
   39      -svg)
   40         SVG=true
   41         ;;
   42      -quant)
   43         shift
   44         echo "Warning: option -quant deprecated" 1>&2
   45         ;;
   46     -extra)
   47         shift
   48         EXTRA="$1"
   49         ;;
   50     -mag)
   51         shift
   52     RESOLUTION="$( expr '(' "$1" '*' 100 '+' 999 ')' '/' 1000)"
   53         ;;
   54     -res)
   55         shift
   56         RESOLUTION="$1"
   57         ;;
   58     -t)
   59         shift
   60         TPAPER="-t $1"
   61         ;;
   62      -pdflatex|-pdf)
   63          LATEX=pdflatex
   64        ;;
   65     -raw)
   66        EXTRA=''
   67        MARGIN=''
   68        TOEXT="pnm:-"
   69       ;;
   70     *)
   71         break
   72         ;;
   73     esac
   74     shift
   75 done
   76 echo "RESOLUTION: $RESOLUTION"
   77 
   78 case $1 in
   79   '')
   80    BASE=image
   81    ;;
   82   *)
   83    BASE=$1
   84   ;;
   85 esac
   86 NAME=${BASE}.image
   87 
   88 trap "${RM} ${NAME}.dvi ${NAME}.pdf `basename ${NAME}.log` `basename ${NAME}.aux` head.tmp body.tmp ${COM} ; exit 2" 1 2 3 8 10 13 15
   89 
   90 DVIPSOPTS="-Z $TPAPER"
   91 GSOPTS="-q -dNOPAUSE -dBATCH -dNOPROMPT -sDEVICE=pngalpha \
   92     -r$RESOLUTION -dAutoRotatePages=/None \
   93         -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dDOINTERPOLATE \
   94         -P- -dSAFER"
   95 
   96 CONVERT="convert png:- ${CROP} ${EXTRA} ${MARGIN} ${TOEXT}"
   97 echo ${CONVERT} > ${COM}
   98 if [ "${TODIR}" = "." ]
   99 then
  100   FINAL=${BASE}%03d.${EXT}
  101 else
  102   FINAL=${TODIR}/${BASE}%03d.${EXT}
  103 fi
  104 test -f  ${NAME}.tex ||\
  105 { echo "Failure: no ${NAME}.tex file!" 2>&1 ; exit 2 ; }
  106 ${LATEX} ${NAME}.tex
  107 NAMEDIR=`dirname ${NAME}`
  108 if [ "${LATEX}" = "pdflatex" ]
  109 then
  110   if [ ${NAMEDIR} != "." ]
  111   then
  112     mv `basename ${NAME}.pdf` ${NAME}.pdf
  113   fi
  114   cat ${NAME}.pdf
  115 else
  116  if [ ${NAMEDIR} != "." ]
  117   then
  118     mv `basename ${NAME}.dvi` ${NAME}.dvi
  119   fi
  120   ${DVIPS} ${DVIPSOPTS} -o - ${NAME}.dvi
  121 fi |\
  122 ${GS} ${GSOPTS} -sOutputFile="| sh ${COM} > ${FINAL}" -
  123 
  124 if $SVG
  125 then
  126   pdflatex  ${NAME}.tex
  127   if [ ${NAMEDIR} != "." ]
  128   then
  129     mv `basename ${NAME}.pdf` ${NAME}.pdf
  130   fi
  131   pdfcrop ${NAME}.pdf ${NAME}.crop.pdf
  132   pdf2svg ${NAME}.crop.pdf "${TODIR}/${BASE}%03d.svg" all
  133   ${RM} ${NAME}.crop.pdf
  134 fi
  135 
  136 ${RM} ${COM} ${NAME}.dvi ${NAME}.pdf  head.tmp body.tmp
  137 ${RM} `basename ${NAME}.log` `basename ${NAME}.aux`