Generating images with PHP is one of my favorite tricks and the ease of doing this in PHP is really a testament the language getting something right. If you’re on the site and not in your RSS aggregator, then you enjoy a generated image on every page on PhotoMatt.net, the titles of each post and the post times graph at the bottom of the page. Combined with image replacement techniques, PHP-generated images can be very useful. This was one of the first blogs I know of to do it, but I’ve seen it on several sites since then and I’ve shared the code with anyone who asks.
However the function I’m using for all of this,
imagettftext is rather crude, and doesn’t allow for much control in how the text is presented. After a bit of work I just created a function that simulates tracking in text images that are created by PHP. I’m happy with structure of the code, but the result is much uglier than if the text had been set by any decent program.
Imagettftext is supposed to support unicode, so I’ll have to investigate using unicode semi-space characters or perhaps interfacing with Freetype more directly.
Anyway, now the image generator takes a background color (which may be transparent), a text color, and a rollover color. Then it generates a single image with the given text in it once with each color, for use with Pixy’s fast rollovers. This is all in the context of the Unamed CMS that is coming Real Soon(tm).