I want to output a PNG image with the standalone package. Here is a minimal working example:

\documentclass[preview, convert={density=300}]{standalone}

    Hello world

When I inspect the file properties of the resulting PNG file, I still get 72 dpi. Even without using the preview option, it's still at 72 dpi. However, if I convert to JPG using convert={density=300, outext=.jpg}, I'd get 300 dpi.

How can this be fixed? My particular requirement would be to use the preview option and use the PNG image format.

  • If I set density=600 in the options, I get PNG image data, 415 x 58 which is twice as the 208 x 29 that you get from the original input. The typeset "Hello world" is 50.02786pt wide, which corresponds to 0.69224in; 300*0.69224=207.672 that justifies the 208 pixels (and also the 415 at 600dpi). – egreg Nov 13 '12 at 21:34
  • Please check if standalone is using Image Magick or Ghostscript internally. Image Magick is the default under Linux if installed. See the manual section 4.6.2 Conversion software for more details. Also please state your standalone version, your LaTeX distribution and your OS. – Martin Scharrer Jan 1 '13 at 11:42
  • @egreg: Could you recheck with the ghostscript option also set. I guess the installation of the OP uses Ghostscript which might cause the issue. – Martin Scharrer Jan 1 '13 at 11:43
  • @MartinScharrer I get the same result with ghostscript: \documentclass[preview, convert={ghostscript,density=300}]{standalone} gives PNG image data, 208 x 29, 8-bit/color RGB, non-interlaced – egreg Jan 1 '13 at 14:16
  • @MartinScharrer With the ghostscript option set, even my image viewer does agree about the density. – Qrrbrbirlbel Jan 1 '13 at 19:26

The package manual states that “the following default settings are used: PNG format, a density of 300dpi, no explicit size […].”

So there's no surprise that density=300 doesn't result in a different output.

I wouldn't trust the “file properties” of the resulting file. How should a picture viewer (or your OS) know what an inch is? It's just pixels at the output side now.

Consider the following example where I typeset a black 1 inch by 1 inch square.

The output .png is 300 pixels by 300 pixels.


    convert% uses default settings: density=300 and png



enter image description here

To complement egreg's comment:


\newlength{\myWidth} \newlength{\myHeight}
\sbox0{Hello world}
\printlength\myWidth${}\times{}$\printlength\myHeight\ (\the\wd0 ${}\times{}$\the\ht0)


enter image description here

  • Could you recheck with the ghostscript option also set. I guess the installation of the OP uses Ghostscript which might cause the issue. See also my comment to the question. – Martin Scharrer Jan 1 '13 at 11:43

I had the same problem and discovered that the convert command was ignoring the density setting unless I explicitly set the units. That is, the command

convert -density 300 foo.pdf foo.png

produces a png file at 72 dpi, but the command

convert -density 300 -units pixelsperinch foo.pdf foo.png

produces a png file at 300 dpi. So I suspect the problem is not with standalone but with the ImageMagick settings. I gave up at this point and simply created an AUCTeX command that issues the correct shell command to the pdf file after it has been LaTeXed, but this may provide a hint for someone else.

If you want to try the solution using AucTeX, customize Tex Command List in AUCTeX and add a command that runs

 mogrify -density 300 -units pixelsperinch -format png %P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.