mkrphys / ipython-tikzmagic

IPython magics for generating figures with TikZ
BSD 3-Clause "New" or "Revised" License
160 stars 44 forks source link

RGB color space not permitted on grayscale PNG #34

Closed MatrixManAtYrService closed 2 years ago

MatrixManAtYrService commented 2 years ago

When I try to use the tikz in the readme:

%%tikz
\draw (0,0) rectangle (1,1);
\filldraw (0.5,0.5) circle (.1);

I get this output:

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Debian) (preloaded format=pdflatex)
 \write18 enabled.
entering extended mode
... some omitted ...
No pages of output.
Transcript written on tikz.log.
convert-im6.q16: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG `tikz.png' @ warning/png.c/MagickPNGWarningHandler/1667.

It would appear that ImageMagick is noticing that the output is not RGB and not-so-helpfully changing the filetype for us as discussed here.

There are proposed solutions in that repo, but how can I make tikzmagic use them?

MatrixManAtYrService commented 2 years ago

A bit more hacking around and I can repoduce this error outside of ipython:

tkiz.tex

\documentclass[convert={convertexe={convert},density=300,size=400x240,outext=.png},border=0pt]{standalone}
\usepackage[]{tikz}

\begin{document}
\begin{tikzpicture}[scale=1,]
\draw (0,0) rectangle (1,1);
\filldraw (0.5,0.5) circle (.1);

\end{tikzpicture}
\end{document}
$ pdflatex --shell-escape tkiz.tex
...
convert-im6.q16: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG `tikz.png' @ warning/png.c/MagickPNGWarningHandler/1667.

It looks like the arguments to documentclass are passed through to imagemagick, but trying to add colorspace=RGB gives an error:

\documentclass[convert={convertexe={convert},colorspace=RGB,density=300,size=400x240,outext=.png},border=0pt]{standalone}

Gives an error:

! Package xkeyval Error: `colorspace' undefined in families `standalone.cls/convert'.

same goes for adding define=colorspace:auto-grayscale=false

MatrixManAtYrService commented 2 years ago

Hahaha, that's a warning, not an error. I had wrongly assumed that it was triggering this functionality., so I set about working around it. But that was silly because pdflatex still returns 0 in the event of warnings.

I found a workaround, but the awkward logs were still showing up. That's a separate issue.