Newer
Older
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
#! /bin/bash
set -e
set -x
if test "$1" = "" || test "$2" = ""; then
echo "Usage: $0 pic.tikz pic.png [CONVERT FLAGS ...]"
exit 1
fi
TIKZ="$1"
OUTF="$2"
shift
shift
TMPDIR=$(mktemp -d)
TEX="$TMPDIR/source.tex"
cat <<END > $TEX
\documentclass[preview]{standalone}
\nonstopmode
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fadings}
\usetikzlibrary{chains}
\usetikzlibrary{scopes}
\usetikzlibrary{shadows}
\usetikzlibrary{arrows}
\usetikzlibrary{snakes}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{fit}
\usetikzlibrary{shapes.arrows}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes.callouts}
\usetikzlibrary{decorations.text}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\renewcommand*\familydefault{\sfdefault}
\begin{document}
END
cat $TIKZ >> $TEX
cat <<END >> $TEX
\end{document}
END
(cd "$TMPDIR"; pdflatex source)
(cd "$TMPDIR"; convert "$@" source.pdf source.png)
cp "$TMPDIR/source.png" "$OUTF"