5

I am using standalone to convert a table to PNG. I have followed the following example. I got the output in PNG as well, please see the attached. However, when I view it with any of the image viewers (GIMP, IMAGEMAGICK etc), the background is not white. It has black and white square boxes. Surprisingly, here it is with white background. I will be very thankful if some one tell me the solution.

I have followed the following example

\documentclass[convert={density=300,size=1080x800,outext=.png}]{standalone}
\begin{document}
\begin{tabular}{rrrrrrr}
\hline
        Device & 2011 & 2012 & 2013 & 2014 & 2015 & 2016 \\
        \hline
        Non-smarthphones & 22686 & 55813 & 108750 & 196262 & 357797 & 615679 \\
        Smarthphones & 104759 & 365550 & 933373 & 1915173 & 3257030 & 5221497 \\
        Laptops e Netbooks & 373831 & 612217 & 917486 & 1340062 & 1963950 & 2617770\\
        Tablets & 17393 & 63181 & 141153 & 300519 & 554326 & 1083895\\
        Home gateways & 55064 & 108073 & 180562 & 267545 & 376494 & 514777 \\
        M2M & 23009 & 47144 & 92150 & 172719 & 302279 & 508022 \\
        Altri devices & 525 & 1460 & 5429 & 22966 & 84204 & 242681\\
        \hline
\end{tabular}
\end{document}

Output from the code Screen shot of the GIMP

1 Answers1

7

This is what I call a hack; the standalone class should have a key for passing other options to convert.

\documentclass[
  convert={
    density=300 -alpha deactivate,
    size=1080x800,
    outext=.png
  },
]{standalone}

\begin{document}

\begin{tabular}{rrrrrrr}
\hline
        Device & 2011 & 2012 & 2013 & 2014 & 2015 & 2016 \\
        \hline
        Non-smarthphones & 22686 & 55813 & 108750 & 196262 & 357797 & 615679 \\
        Smarthphones & 104759 & 365550 & 933373 & 1915173 & 3257030 & 5221497 \\
        Laptops e Netbooks & 373831 & 612217 & 917486 & 1340062 & 1963950 & 2617770\\
        Tablets & 17393 & 63181 & 141153 & 300519 & 554326 & 1083895\\
        Home gateways & 55064 & 108073 & 180562 & 267545 & 376494 & 514777 \\
        M2M & 23009 & 47144 & 92150 & 172719 & 302279 & 508022 \\
        Altri devices & 525 & 1460 & 5429 & 22966 & 84204 & 242681\\
        \hline
\end{tabular}
\end{document}

enter image description here

egreg
  • 1,121,712
  • Thank you very much. It worked. \documentclass[ convert={ density=300 -alpha deactivate -background white, size=1080x800, outext=.png }, ]{standalone} – Rajagopal Jun 08 '15 at 21:35
  • 1
    @egreg Neither the answer nor the answer with the additional "-background white" produce a white background—at least not with TeX Live 2015. The background remains transparent in both cases. – Calaf Jun 29 '16 at 16:24
  • @Calaf I get white background. What OS are you on? – egreg Jun 29 '16 at 19:44
  • @egreg I'm on OS X 10.11.5 (El Capitan). – Calaf Jun 29 '16 at 20:03
  • @Calaf I'm too. – egreg Jun 29 '16 at 20:11
  • @egreg Interesting... Could ImageMagick be the culprit on my side? convert --version gives me: Version: ImageMagick 6.9.3-4 Q16 x86_64 2016-02-29. – Calaf Jun 29 '16 at 22:11
  • @Calaf I have Version: ImageMagick 6.9.4-9 Q16 x86_64 2016-06-13 – egreg Jun 29 '16 at 22:13
  • @egreg It got weirder after I upgraded. I asked: http://tex.stackexchange.com/q/317277/9549 – Calaf Jun 29 '16 at 23:35
  • For ImageMagick 7.0.7-21 Q16 x64 2018-01-06 the only command that seems to work is magick input.pdf -alpha remove output.png. The problem is that -alpha must be between two files, so appending it to density value (which comes before the first file) does not work. There is a way to reconstruct the command that is sent by standalone (sub-option command, Pg. 17 in manual), which however does not work. – Pygmalion Feb 05 '18 at 08:42
  • @Pygmalion I have ImageMagick 7.0.7-22 Q16; the command convert -density 300 -alpha deactivate test.pdf test.png works, and indeed the test above runs without problems. – egreg Feb 05 '18 at 08:55
  • Even with the newest version (ImageMagick 7.0.7-22 Q16 x64 2018-01-22) this command returns no images found for operation '-alpha' at CLI arg 3 @ error/operation.c/CLIOption/5266 – Pygmalion Feb 05 '18 at 09:08
  • @Pygmalion It does for me, but I don't have Windows. – egreg Feb 05 '18 at 09:09
  • Oh well, then imagemagick is pain in the ass with its ever changing command parameters and incompatibility between different systems. – Pygmalion Feb 05 '18 at 09:11
  • @Pygmalion It used to be even worse when GraphicsMagick had its own convert program; then I guess both teams realized that having convert was a nuisance, particularly on Windows that has its own too. – egreg Feb 05 '18 at 09:16
  • What if the table is in landscape mode and is also containing refs. – user3582228 Feb 24 '22 at 12:07