Dynamic Text Graphics w/ Apache?
An Anonymous Internet Freak asks:
"I have recently been made aware of a very useful feature in Roxen Webserver. It allows you to embed text into a html document, which the server coverts to a graphic containing that text. Eg. I want a button that says 'Home', so I include a command within the HRML code. As the page goes through the server, it dynamically creates an image containing that 'Home' at the defined size/colour etc. Can Apache do the same?" It shouldn't be too hard to do something like this in Perl with an early version of GD. Watch out for the
licensing police, however! What do you all think? Is there a better solution?
- Pass 1: Source Reading and Include File Expansion (ipp)
- Pass 2: Meta HTML Macro Construct Expansion (mhc)
- Pass 3: Perl 5 Programming Construct Expansion (eperl)
- Pass 4: M4 Macro Construct Expansion (gm4)
- Pass 5: Diversion Filter (divert)
- Pass 6: Character and String Substitution (asubst)
- Pass 7: HTML Fixup (htmlfix)
- Pass 8: Line Stripping and Output Fixup (htmlstrip)
- Pass 9: Output Splitting and Final Writing (slice)
might be what you're looking for -- specifically the gfont program that comes with the distrib.--
W.A.S.T.E.
W.A.S.T.E.
I have something like this working under PHP3, which runs as an Apache module. It caches the generated GIF so it does not have to regenerate it every time.
It was not hard to put together, although it is not currently in a ready-to-distribute state.
To stick graphic text in, I do something like this, using brackets instead of braces to slashdot doesn't nuke it:
[img src="/text.php?text=Hello+World&size=15"]
It's not as seamless as what Roxen does, but it works fine.
As the question points out, it has to use an old GD that has GIF support.
function pngtext($textstr) {
}
};
(Wow, that would have been *much* easier if <pre> was allowed. I did that with nested <blockquote>s.)
PHP3 also has functions for generating graphics on the fly. They are described at www.php.net.
I've seen Perl scripts that generate graphics on the fly, so if you're more versed in that, try it out.
If cascading style sheets can't give you the effect you want, then just give up. Pictures of letters is a dumb idea - they can't be resized, they can't be cut and pasted, they can't be read by computer or search engine, they increase latency, and they might not be anti-aliased against the background displayed by the browser. Just say no to pictures of text.
http://www.goof.com/pcg/marc/gimp.html I've done it, it works nicely.
--
http://www.wholepop.com/
Whole Pop Magazine Online - Pop Culture
http://www.wholepop.com/
Whole Pop Magazine Online - Pop Culture
Java Servlets are also much more efficient than Perl CGI. You don't want to bog down your server for a cute little graphic effect!