Created
September 1, 2024 08:32
-
-
Save mistivia/f29a4f2be6c58af19bfd5fa65daba0a2 to your computer and use it in GitHub Desktop.
convert latex formula to jpeg image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # usage: echo '$$E=mc^2$$' | tex2jpg out.jpg | |
| PPWD=$(pwd) | |
| DIR=/tmp/$(head -c10 /dev/urandom | base32) | |
| mkdir -p $DIR | |
| cd $DIR && \ | |
| echo '\documentclass{minimal}' > input.tex && \ | |
| echo '\begin{document}' >> input.tex && \ | |
| echo '' >> input.tex && \ | |
| cat >> input.tex && \ | |
| echo '' >> input.tex && \ | |
| echo '\end{document}' >> input.tex && \ | |
| cat input.tex && \ | |
| latex input.tex && \ | |
| magick convert -density 300 input.dvi -trim -bordercolor white -border 20 out.jpg && \ | |
| cd $PPWD && \ | |
| cp $DIR/out.jpg $1 | |
| rm -rf $DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment