Graphical images script
November 12, 2004 12:23 PM   Subscribe

I am looking for a simple script (perl,php,whatever) or even binary utility that can programatically render graphical images in this manner: take XYZ font (true-type/postscript/whatever) and render an image with the text ABC.

Does such a thing exist?
posted by xmutex to Computers & Internet (13 answers total)
What platform are you using? I know that ImageMagick can do this on the command line. It also has bindings for most scripting languages, and is available on every platform.
posted by Eamon at 12:29 PM on November 12, 2004

By render, I don't suppose you'd be happy with it rendered in a browser window (easy to do with JavaScript)?
posted by jpburns at 12:31 PM on November 12, 2004

I've used ImageMagick and GD for these things, both work OK.
posted by RustyBrooks at 12:33 PM on November 12, 2004

Response by poster: Unix platform. Not wanting it to render in a browser, but to output files. Think like a GIF-based blog.

But not annoying!
posted by xmutex at 12:35 PM on November 12, 2004

I was thinking you were looking for a way to create spam-proof email addresses on the fly.
posted by terrapin at 12:43 PM on November 12, 2004

If you're going to be writing a LOT of text (e.g., for a "GIF-based blog"), you may want to look into using LaTeX.

It will typeset your text and produce a DVI file, which can then be converted to GIF. This way, you won't have to worry about things like line-breaks. Don't worry, LaTeX isn't hard to learn for simple prose. Anyone who knows HTML should be able to pick it up in minutes.
posted by Eamon at 12:44 PM on November 12, 2004

photomatt has been doing this for a while on his blog (here's a random entry). The title is a graphic, which I'm guessing imagemagik did on the fly using the GD php libraries.
posted by mathowie at 12:47 PM on November 12, 2004

Response by poster: Thanks all. ImageMagick seems to be the solution. Time to go hack away.
posted by xmutex at 12:53 PM on November 12, 2004

A List Apart did an article about this, Dynamic Text Replacement. Looks like just want you want.
posted by delfuego at 12:56 PM on November 12, 2004

Use PHP GD. The standard builds include it and it's apparently 6 lines of code to make one, here:

header ("Content-type: image/png");
$img_handle = ImageCreate (250, 80) or die ("Cannot Create image");
$back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
$txt_color = ImageColorAllocate ($img_handle, 255, 255, 255);
ImageString ($img_handle, 31, 50, 5, "GET UP OFFA THAT THING", $txt_color);
ImagePng ($img_handle);

posted by holloway at 4:40 PM on November 12, 2004

Oh, and then you could just wget that webserver/makeimage.php?text=GET%20UP%20OFFA%20THAT%20THING to get a local copy.
posted by holloway at 4:43 PM on November 12, 2004

You may want to look into sIFR, which uses javascript and flash. Advantages: pulls the text straight out of the web page. Disadvantages: without javascript or flash available, plain text is displayed.
posted by Nothing at 5:33 PM on November 12, 2004

I have used the "dynamic text replacement" script on ALA, and it works like a charm, provided your internet provider has enabled the GD image library in PHP.
posted by Civil_Disobedient at 9:21 PM on November 12, 2004

« Older Restaurant Reservations   |   How are flash sites like Virtual Bartender and... Newer »
This thread is closed to new comments.