Is there a way to save or export a tex file so as to produce a jpg/jpeg/png file?
Asked
Active
Viewed 837 times
0
Dr. Manuel Kuehner
- 22,451
Frode Alfson Bjørdal
- 4,817
1 Answers
2
- Go to https://imagemagick.org/script/download.php and download the appropriate version. In my case (Windows) it is
ImageMagick-7.0.9-12-Q16-x64-dll.exe(as of 2019-12-29). - Go to https://www.ghostscript.com/download/gsdnld.html and download the appropriate version. In my case (Windows) it is
Ghostscript 9.50 for Windows (32 bit)(GNU Affero General Public License). ImageMagick calls ghostscript for converting PDF as far as I understand. - Generate a LaTeX file (
test.tex) and produce a single PDF page.
\documentclass{article}
\begin{document}
Test
\end{document}
- In the same folder, create a text (
myConvertBatch.txt) file with the following content (-density 300is for better quality/resolution).
magick -density 300 test.pdf test.png
pause
- Rename the text file to
myConvertBatch.bat. - Double-click on
myConvertBatch.bat-- this should generatetest.png. - Look into the
standalonedocument class (https://ctan.org/pkg/standalone).
For more details about the options of the magick command, see https://imagemagick.org/script/command-line-processing.php.
Related
- https://www.imagemagick.org/discourse-server/viewtopic.php?t=16045
- http://www.imagemagick.org/discourse-server/viewtopic.php?t=19367
- Standalone Package | Convert Option | Issues With Command Option | PNG Export | Remove Alpha | Remove Transparency
- Exporting .png or .jpg files directly from LaTeX code. Possible?
Dr. Manuel Kuehner
- 22,451
-
-
1@Sapiens Don't know what
Homebrewmeans?! Going to bed now anyway, it's 04:38 o'clock in the morning for me :) (China timezone). – Dr. Manuel Kuehner Dec 28 '19 at 20:38 -
Imagemagick recommends and use Homebrew commands for installation explanations for Mac-users. – Frode Alfson Bjørdal Dec 28 '19 at 21:07
-
-
Thank you for the ample answer! I hope I will be able to implement it soon by installing the appropriate software. – Frode Alfson Bjørdal Dec 29 '19 at 15:24


standaloneclass has aconvertoption that is precisely made for that. There are several examples on this site, here is a post by the package author. In addition, if you produce the pictures withasymptote, there is thesettings.outformatdirective, e.g.settings.outformat = "png";. – Dec 28 '19 at 19:41convertwhich can be used for conversion. Or use GhostScript. – Dr. Manuel Kuehner Dec 28 '19 at 20:13