magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 2000 > 09 > Programming with Perl  

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



  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2