blog

dvipng color trouble

I still have yet to find a fix to the dvipng discoloration mystery I ran into back at The Academic Approach, even with the latest MacTeX version, so I’m going to repost the problem here.

In May 2007, I wrote the following to the OS X TeX listhost:1

Hi all,

I’ve recently run into what I believe is a rare bug in dvipng: here’s the setup. (To play along, you can get my test files: http://mitcho.com/discolor.zip .) I am using MacTeX… in fact, it’s today’s release.

The LaTeX source file (discolored.tex) loads just two packages: color and graphicx. The body does two things: an \includegraphics with a local PNG file (with the bb option to specify the BoundingBox explicitly) and a \textcolor command introducing some green text, using the green defined there.

pdflatex produces the expected result: the figure and the green text.

Original color

But when you run the following commands…

latex discolored.tex

dvipng -D 200 discolored.dvi

you get a PNG (discolored1.png) which shows the text in a brownish color… the green is gone!!

Discolored version

There are two quick ways to fix this that I’ve found: one is to not include the image… if you comment the \includegraphics command out, the color comes out fine. The second is to not specify a -D (output resolution) parameter in the dvipng… this also gives you the expected output. However, in my current project, neither of these are available options…

I am frankly not very familiar with the inner workings of dvipng… does anyone have any thoughts? Can this bug be reproduced?

Any hints or suggestions are welcome!

Ditto.

discolor.zip
496 kb - zip

  1. Inline cropped images added to this web version, just to spice things up. 

Related posts:

  1. Markdown for WordPress and bbPress: Markdown for WordPress and bbPress 1.0 30 kb - zip...

関連記事は Yet Another Related Posts Plugin によって表示されています。

Tags: , , ,

If you enjoyed this post, make sure you subscribe to my RSS feed (optionally with tweets from my Twitter)!

One Response to “dvipng color trouble”

  1. Jan-Åke Larsson Says:

    I know quite a lot about the inner workings of dvipng; I wrote it.

    The MacTeX distribution uses a really really outdated version of libgd: the truecolor-incapable libgd1.x which has been replaced by the truecolor-capable libgd2.x, I dunno, 5-6-7 years ago.

    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 libgd1-compatibility code in dvipng and force everyone to go libgd2.)


© 2006-2008 mitcho (Michael 芳貴 Erlewine).
Proudly powered by WordPress.
Entries (RSS) and Comments (RSS).
The views expressed on these pages are mine alone and do not
reflect those of my employers and clients, past and present.