[Tex/LaTex] Standalone package advanced conversion options inside LaTeX source file

conversionstandalone

I want to use the conversion options of the standalone package to produce a PNG image file from a LaTeX source file. The package documentation lists two tables with options for conversion. The normal options are usable inside the convert class options, the advanced options are usable inside … that's the question now. From the documentation examples and experiments I know that they are usable within a standalone.cfg file. But, my question is, if I could use them inside my source files directly somehow.

Here is a MWE of something I tried:

\documentclass[convert={density=600,size=400x400,outext=.png},crop,border=0mm]{standalone}
\usepackage{tikz}

% The following options are ignored at this place.
% It works if this is put inside a 'standalone.cfg' file
\standaloneconfig{convert={command={\convertexe\space -density \density\space
  \infile\space
  \ifx\size\empty\else -resize \size\fi\space
  -quality 100\space
  -define png:format=png32\space
  -define png:compression-filter=4\space
  \outfile}}}

\begin{document}
\begin{tikzpicture}
\shadedraw [shading=ball] (0,0) circle (2cm);
\end{tikzpicture}
\end{document}

enter image description here

  • Putting the options inside the \standaloneconfig macro of the given MWE is ignored.
  • Putting the options inside the class options (I tried several things) leads to compilation errors.

Is there a solution where and how to put the options inside my source file or am I forced to use the standalone.cfg file? I would consider to have all options in one file a very desirable feature. Maybe, I'm just applying things wrong?

Update:
Since nobody answered or commented my question the last two days, I guess it's not possible to use the advanced conversion options inside the source file (?). I would appreciate any comment … can't imagine nobody tried this before …

Best Answer

According to the documentation, is only possible if you set it within "standalone.cfg" not within the document, however, is more like using:

\documentclass[convert={density=600,size=400x400,outext=.png},crop,border=0mm]{standalone}
\usepackage{filecontents}
\begin{filecontents}{standalone.cfg}
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{standalone.cfg}[2012/09/15 v1.1b Default configuration file for 'standalone' class]%
% The following options are ignored at this place.
% It works if this is put inside a 'standalone.cfg' file
    \standaloneconfig{convert={command={\convertexe\space -density \density\space
      \infile\space
      \ifx\size\empty\else -resize \size\fi\space
      -quality 100\space
      -define png:format=png32\space
      -define png:compression-filter=4\space
      \outfile}}}
\end{filecontents}
\usepackage{tikz}
\usepackage{bashful}
\begin{document}
\begin{tikzpicture}
\shadedraw [shading=ball] (0,0) circle (2cm);
\end{tikzpicture}
\end{document}

the log :

 runsystem(convert -density 600 uno.pdf -resize 400x400 -quality 100 -define png
:format=png32 -define png:compression-filter=4 uno.png)...executed.

or

mogrify -resize 400x400 -quality 100  -define png:format=png32 -define png:compression-filter=4 -format png *.png

after compiled document (mogrify prserve name of the image files :). regards