# How can I use arara to get a graphics file?

In a standard TeX Live distribution Ghostscript is, to my knowledge, present; it is hidden, but it is there.

Edit: Yes, it is under

\Texlive\2013\tlpkg\tlgs


So to my question:

How can I use arara, to activate the internal Ghostscript to get a graphics file as an output? For example mydocument.png (in addition to mydocument.pdf).

Note, that I do not ask, how can I convert a PDF to a PNG (we know there are 1000s of possibilities), I am interested to use only internal TeX Live tools (that means NO extra software) and let arara do the job.

-
Knowing how you would use ghostscript to make the PNG files from the PDF is better. Is it a single page PDF? Do you want to crop it to a minimal bounding box? However, as far as I know, ghostscript is not included in TeX Live. – egreg May 11 '14 at 19:59
Oh, that is a good question. For example: I create a TikZ-picture in the standalone-class, so I am interessted to have that as a png. I also thought about the preview-package, to get special parts of my document as a preview; and this I would like to have as a png too ;) – cis May 11 '14 at 20:02
Which platform are you on? MacTeX includes some extras although it did not used to provide ghostscript as far as I know. It did used to provide a stripped down convert independent of ImageMagick. No idea if I am misremembering or if, if not, it still does, though... – cfr May 12 '14 at 1:42
Ghostscript can be found under \Texlive\2013\tlpkg\tlgs in windows ;) – cis May 12 '14 at 13:58

Here's a simple way to get what you need with standalone:

% arara: pdflatex: { shell: yes }
\documentclass[
convert,
outext=.png,
tikz,
]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) .. controls (1,1) and (2,1) .. (2,0);
\end{tikzpicture}
\end{document}


This will use convert and needs ImageMagick, which can be easily installed. Conversion using ghostscript is possible, but you need tweaking the parameters. With the default ones, the conversion with convert is good, with ghostscript (that you get by convert=ghostscript) is quite bad.

The conversion with ghostscript is obtained with

% arara: pdflatex: { shell: yes }
\documentclass[
convert=ghostscript,
tikz,
]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw (0,0) .. controls (1,1) and (2,1) .. (2,0);
\end{tikzpicture}
\end{document}


Examining the .log file I see

runsystem(gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 -sOutputFile=gsconv-%d.png gsconv.pdf)...executed.


which shows that ghostscript is called. You may need to do some adjustment to the internal parameters, in particular for helping standalone in finding the ghostscript executable. I can't be more precise, because I don't have Windows (and never will).

-
Thank you! So we have a solution with the extra-software ImageMagick. But I ask me, if there is a elementary solution with the ghostscript, wich you can found under \Texlive\2013\tlpkg\tlgs (in Windows)? – cis May 12 '14 at 14:02