Discussion:
[Dvipng] Re: dvipng color trouble
Jan-Åke Larsson
2008-01-10 09:20:37 UTC
Permalink
Thank you for your great work on dvipng. I can't remember if I tried to
contact you previously when I encountered this issue, but I just posted
about a rare coloration bug in dvipng... I would love to know what you
http://mitcho.com/blog/2007/12/28/dvipng-color-trouble/
The DVI on your webpage works for me (dvipng >= v1.8), but I have been
able to reproduce your behaviour by giving the --palette switch. Is it
possible that you are using that switch too? In that case, what is
probably happening is that the included image fills the color palette
before the green color is allocated, there are only 256 colors in a
palette PNG.

The "fixes" described on your web page resolve this because a) when not
setting the resolution, the default 100 DPI causes the image to be
scaled in such a way that it does not fill the color palette, probably
just by sheer luck. b) not including the image will of course not fill
the color palette.

I have tried setting the color before the page inclusion, but to
allocate the color in the PNG palette, there needs to be some output on
the page. Just selecting the color via

\textcolor{green}{}

before the image inclusion is not enough. dvipng tries to be economical
with allocated colors and does not allocate it until it is used. One way
of resolving this would be to do (before the image inclusion)

\textcolor{green}{Color allocation}
\newpage

My recommended solution would be to allow truecolor output by removing
the --palette switch. It is the real cause for your trouble, after all.

/JÅ
--
SIGSIG -- signature too long (core dumped)
Jan-Åke Larsson
2008-01-10 09:44:45 UTC
Permalink
One way of resolving this would be to do (before the image inclusion)
\textcolor{green}{Color allocation}
\newpage
I forgot: the color palette is page-specific. So you need to output the
green text before the image inclusion _on_each_page_.

You need to do something like

\phantom{\includegraphics[bb=0 0 300 274]{figure}}

\textcolor{green}{This text is green.}

\vspace{-3.81in} % 274/72 in
\vspace{-1.2\baselineskip}
\includegraphics[bb=0 0 300 274]{figure}

The first is to leave space for the image, and the second includes the
image in the right place. This does the work, but is not recommended.

Recommended solution is still to allow truecolor output.

/JÅ
--
"Reality is that which when you stop believing in it does not go away."
Philip K. Dick
Jan-Åke Larsson
2008-01-10 10:35:23 UTC
Permalink
Hi Jan,
No, I actually was not using --palette. I know truecolor should
automatically be turned on in this case... I just tried to force
$ dvipng --truecolor -D 200 discolored.dvi
This is dvipng 1.9 Copyright 2002-2006 Jan-Ake Larsson
dvipng: Fatal error, papersize ruecolor is not implemented
It's apparently recognizing it as a -t papersize option... I know that
others on the listhost were able to reproduce this issue without
--palette as well. I'm using the MacTeX distribution.
OK, that means that the MacTeX distribution has a really really outdated
version of libgd. It is using the truecolor-incapable libgd1.x which has
been replaced by the truecolor-capable libgd2.x, I dunno, 5-6-7 years ago.

The incanatation I sent you will work.

But the best course of action would be to rebuild dvipng against libgd2.
And to recommend the distributor of MacTeX to do so too. (Perhaps I
should just remove the compatibility code and force everyone to go libgd2.)

/JÅ
--
Cats humour us because they know that their ancestors ate ours
Loading...