3

I can successfully create PDF figures using TikZ and convert them with convert (ImageMagick) to PNG such that retain a transparent background. However, with the same procedure, for some of my figures, I instead get a white background. It seems that this happens whenever I have semi-transparent elements in the figure (see another SE-question, where this conclusion is implicit in the answer). This is on Mac OS X. If I use Inkscape, I can get a semi-transparent background, but it typically messes up the fonts (and I don't know how to do it via the CLI).

MWE:

\RequirePackage{luatex85}
\documentclass{standalone}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[blue,fill=green,fill opacity=0.1] (0,0) circle (1);
\end{tikzpicture}
\end{document}

The \RequirePackage{luatex85} is there because I use a very recent LuaTeX that causes problems with some packages. Convert with convert -background transparent test.pdf test.png. The result is:

Result after conversion

If fill opacity=0.1 is removed, the result looks as follows:

Result after conversion, with fill opacity removed

  • As usual, we can do nothing without a MWE to test things on. – John Kormylo Feb 12 '17 at 20:49
  • You are right of course, here it is. – burnpanck Feb 12 '17 at 21:40
  • Here, with convert version 6.8.9-9, I get the correct result. – Paul Gaborit Feb 12 '17 at 21:59
  • 1
    Interesting! My convert is version 6.9.7-1. Is it a MacOSX specific thing? Or is lualatexthe problem (mine is 0.95.0, TeX Live 2016) ? – burnpanck Feb 12 '17 at 22:23
  • I ran it with pdflatex and lualatex (minus the luatex85, which crashed) and converted with Adobe Acrobat and GIMP with no problems. Gimp offered removing hidden or transparent layers as an option. – John Kormylo Feb 13 '17 at 2:56
1

convert calls gs (ghostscript) to convert a PDF file to PNG. gs version 9.10 seems produce a white background if the PDF file contains semi-transparent objects. A recent version of gs (as 9.19 or 9.20) produces the correct result.

enter image description here

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.