allow choice of background

This commit is contained in:
gutmet 2020-11-25 13:39:14 +01:00
parent 218dd8d7b0
commit ddc125a57d

View File

@ -2,9 +2,20 @@
set -e
if [ "$#" -ne 2 ]; then
echo "Usage: `basename $0` COLOR LATEXSRC"
echo
echo "with COLOR being either a single color for text on transparent background or 'color1 on color2'"
exit 1
fi
color=$1
input=$2
fg="${color% on *}"
bg="${color##* on }"
outpdf="/tmp/latexpic.pdf"
outpng="/tmp/latexpic.png"
@ -19,12 +30,16 @@ cat <<EOF | pdflatex --output-directory /tmp --jobname latexpic --
\usepackage{amssymb}
\usepackage{graphicx}
\color{$1}
\color{$fg}
\begin{document}
$input
\end{document}
EOF
convert -density 600 "$outpdf" -quality 90 "$outpng"
if [ "$fg" = "$bg" ]; then
convert -density 600 "$outpdf" -quality 90 "$outpng"
else
convert -background "$bg" -flatten -density 600 "$outpdf" -quality 90 "$outpng"
fi
xdg-open "$outpng"