/usr/bin/imagen is in hevea 1.10-14.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | #! /bin/sh
LATEX=latex
DVIPS=dvips
GS=gs
RESOLUTION=100 # resolution in dpi
PNMCROP="pnmcrop -white"
PNMEXTRA=""
PNMMARGIN="pnmmargin -white 1"
PPMQUANT=""
PPMTOEXT="pnmtopng -transparent '#ffffff'"
EXT=png
#PPMTOEXT="ppmtogif -transparent '#ffffff'"
#EXT=gif
TODIR="."
RM="/bin/rm -f"
while true
do
case $1 in
-todir)
shift
TODIR="$1"
mkdir -p ${TODIR} 2> /dev/null || :
;;
-gif)
PPMTOEXT="ppmtogif -transparent '#ffffff'"
EXT=gif
;;
-png)
PPMTOEXT="pnmtopng -transparent '#ffffff'"
EXT=png
;;
-pnm)
PPMTOEXT=cat
EXT=pnm
;;
-quant)
shift
PPMQUANT="ppmquant $1 2>/dev/null |"
;;
-extra)
shift
PNMEXTRA="$1 |"
;;
-mag)
shift
RESOLUTION="$( expr '(' "$1" '*' 72 '+' 999 ')' '/' 1000)"
;;
-res)
shift
RESOLUTION="$1"
;;
-t)
shift
TPAPER="-t $1"
;;
-pdflatex|-pdf)
LATEX=pdflatex
DVIPS=cat
;;
*)
break
;;
esac
shift
done
echo "RESOLUTION: $RESOLUTION"
#always quantize for gifs (ppmtogif ouputs non valid files when colors >= 256)
if [ "$EXT" = "gif" -a -z "$PPMQUANT" ]
then
PPMQUANT="ppmquant 255 2>/dev/null |"
fi
case $1 in
'')
BASE=image
;;
*)
BASE=$1
;;
esac
NAME=${BASE}.image
trap "${RM} ${NAME}.dvi ${NAME}.pdf `basename ${NAME}.log` `basename ${NAME}.aux` head.tmp body.tmp ; exit 2" 1 2 3 8 10 13 15
DVIPSOPTS="-Z $TPAPER"
GSOPTS="-q -dNOPAUSE -dBATCH -DNOPROMPT -sDEVICE=ppmraw \
-r$RESOLUTION -dTextAlphaBits=2 -P- -dSAFER"
if [ "${TODIR}" = "." ]
then
FINAL=${BASE}%03d.${EXT}
else
FINAL=${TODIR}/${BASE}%03d.${EXT}
fi
test -f ${NAME}.tex ||\
{ echo "Failure: no ${NAME}.tex file!" 2>&1 ; exit 2 ; }
${LATEX} ${NAME}.tex
NAMEDIR=`dirname ${NAME}`
if [ "${LATEX}" = "pdflatex" ]
then
if [ ${NAMEDIR} != "." ]
then
mv `basename ${NAME}.pdf` ${NAME}.pdf
fi
cat ${NAME}.pdf
else
if [ ${NAMEDIR} != "." ]
then
mv `basename ${NAME}.dvi` ${NAME}.dvi
fi
${DVIPS} ${DVIPSOPTS} -o - ${NAME}.dvi
fi |\
${GS} ${GSOPTS} -sOutputFile="|\
${PNMCROP} | ${PNMEXTRA} \
${PNMMARGIN} | ${PPMQUANT} \
${PPMTOEXT} 2>/dev/null > ${FINAL}" -
${RM} ${NAME}.dvi ${NAME}.pdf head.tmp body.tmp
${RM} `basename ${NAME}.log` `basename ${NAME}.aux`
|