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 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 color=$1
input=$2 input=$2
fg="${color% on *}"
bg="${color##* on }"
outpdf="/tmp/latexpic.pdf" outpdf="/tmp/latexpic.pdf"
outpng="/tmp/latexpic.png" outpng="/tmp/latexpic.png"
@ -19,12 +30,16 @@ cat <<EOF | pdflatex --output-directory /tmp --jobname latexpic --
\usepackage{amssymb} \usepackage{amssymb}
\usepackage{graphicx} \usepackage{graphicx}
\color{$1} \color{$fg}
\begin{document} \begin{document}
$input $input
\end{document} \end{document}
EOF EOF
if [ "$fg" = "$bg" ]; then
convert -density 600 "$outpdf" -quality 90 "$outpng" convert -density 600 "$outpdf" -quality 90 "$outpng"
else
convert -background "$bg" -flatten -density 600 "$outpdf" -quality 90 "$outpng"
fi
xdg-open "$outpng" xdg-open "$outpng"