Getting Image Colors to Text
By Randal L. Schwartz
I've been participating in the perlmonks.org Web site for the past few months. It's a nice setup, based on some discussion software that resembles slashdot.org in many ways, although I think it uses a different code base. Recently, someone posted a comment that directed me to a curious Web page, made up of a series of characters of varying colors that formed an image when taken as a whole. I thought this rather interesting, and examined the source to see that it was huge pile of HTML that looked like:
<font color="#ff00ff">X<font color="#ffff00">Y
which would generate a purple X followed by a yellow Y. Now, this is illegal HTML, because the font tags aren't closed, but my browser didn't complain. I complained at the download time, but that's another matter.
In the thread of messages that followed, I learned that the curious page was actually the product of png2html (see www.engr.mun.ca/~holden/png2html.html for download information). I downloaded the code, and screamed that there was certainly no point in using C to do something I could easily do in Perl. png2html uses the famous graphics library called GD. GD has a Perl binding, so I thought I'd just create a new version in Perl and publish it here.
Choosing Your Pallet
Well, I started with GD (actually, the GD Perl module found in the
|