]> granicus.if.org Git - graphviz/commitdiff
Use Ryan's improved ps_to_png.sh
authorellson <devnull@localhost>
Sat, 4 Oct 2008 22:13:36 +0000 (22:13 +0000)
committerellson <devnull@localhost>
Sat, 4 Oct 2008 22:13:36 +0000 (22:13 +0000)
doc/infosrc/ps_to_png.sh [new file with mode: 0755]

diff --git a/doc/infosrc/ps_to_png.sh b/doc/infosrc/ps_to_png.sh
new file mode 100755 (executable)
index 0000000..2a7a59b
--- /dev/null
@@ -0,0 +1,28 @@
+#! /bin/bash
+
+# Written by Ryan Schmidt.  Oct 4, 2008
+
+# render postscript at this magnification, then scale back down to get antialiasing
+aafactor=4
+
+# add a border of this many pixels around final image
+border=4
+
+scale() {
+    echo $1 | awk -F x -v scale=$2 '{printf("%.0fx%.0f", $1 * scale, $2 * scale)}'
+}
+
+# compute inverse of aafactor for use with pamscale whose -reduce option seems broken
+aafactorinv=$(echo "scale=4; 1/$aafactor" | bc)
+
+# convert scale factor so it gives 96-dpi output instead of 72-dpi output
+scale=$(echo "scale=4; $aafactor*96/72" | bc)
+
+# compute bounding box of initial rendering
+bb=$(scale $(grep PageBoundingBox $1 | awk -f sz.awk) $scale)
+
+# compute resolution at which to render
+res=$(scale 72x72 $scale)
+
+# render it
+gs -sDEVICE=ppmraw -g$bb -r$res -sOutputFile=- -dNOPAUSE -q $1 -c showpage -c quit | pnmcrop | pamscale $aafactorinv | pnmmargin -white $border | pnmtopng > $2