prefwidth=640
prefheigh=480
prefratio=$(( 1000 * $prefwidth / $prefheigh ))
tmpfilename=`mktemp simpleviewer.XXXXXX`
epstopdf --nogs $1 > $tmpfilename
epswidth=`identify $tmpfilename | cut -d " " -f 3 | cut -d x -f 1`
epsheigh=`identify $tmpfilename | cut -d " " -f 3 | cut -d x -f 2`
aspectra=$(( 1000 * $epswidth / $epsheigh ))
if test $aspectra -ge $prefratio
then resol=$(( 72 * $prefwidth / $epswidth )) 
else resol=$(( 72 * $prefheigh / $epsheigh ))
fi
echo "                                             Resolution:" $resol "dpi."
gs -q -r$resol -sDEVICE=x11 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 $tmpfilename
rm $tmpfilename