| 1 | #! /bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # Written by Ryan Schmidt. Oct 4, 2008 |
| 4 | |
| 5 | # render postscript at this magnification, then scale back down to get antialiasing |
| 6 | aafactor=4 |
| 7 | |
| 8 | # add a border of this many pixels around final image |
| 9 | border=4 |
| 10 | |
| 11 | scalescip-shell shell graphviz 14.1.2-1 scale().() { |
| 12 | echoscip-shell system . . echo. $1 | awkscip-shell system . . awk. -F x -v scale=$2 '{printf("%.0fx%.0f", $1 * scale, $2 * scale)}' |
| 13 | } |
| 14 | |
| 15 | # compute inverse of aafactor for use with pamscale whose -reduce option seems broken |
| 16 | aafactorinv=$(echoscip-shell system . . echo. "scale=4; 1/$aafactor" | bc) |
| 17 | |
| 18 | # convert scale factor so it gives 96-dpi output instead of 72-dpi output |
| 19 | scale=$(echoscip-shell system . . echo. "scale=4; $aafactor*96/72" | bc) |
| 20 | |
| 21 | # compute bounding box of initial rendering |
| 22 | bb=$(scalescip-shell shell graphviz 14.1.2-1 scale(). $(grepscip-shell system . . grep. PageBoundingBox $1 | awkscip-shell system . . awk. -f sz.awk) $scale) |
| 23 | |
| 24 | # compute resolution at which to render |
| 25 | res=$(scalescip-shell shell graphviz 14.1.2-1 scale(). 72x72 $scale) |
| 26 | |
| 27 | # render it |
| 28 | gs -sDEVICE=ppmraw -g$bb -r$res -sOutputFile=- -dNOPAUSE -q $1 -c showpage -c quit | pnmcrop | pamscale $aafactorinv | pnmmargin -white $border | pnmtopng > $2 |