Hi I would like to add some dynamic generated graphics to my site and find GD being the one to use. However I'm not sure _how_ to use it on my pages.
I use HTML::Mason for content management and I am very happy and truly amazed of the powers in Mason, but when I tried adding some GD it got me puzzled. When I create a new GD::Image drawing whatever on it and trying to print it - it will be prepended to my html header for the page. I then tried to put it in $m->out to have in printed within Mason, but that simply printed the raw PNG in all its glory as text on screen. I tried fiddeling with content_type, but I guess that wont work if I set this after I have already printed something on the page - hence the content_type will not even be effective for that page. What I still miss doing/trying is making a seperate file/component which only job will be to make the PNG, but I don't really see what I would gain from that, because that will pretty much also just print a PNG "within" my HTML page. Like: <html> <head> </head> <body> Some standard html text... <%perl> $m->content_type( "image/png" ); #my Mason/perl code for creating an image with GD. my $image = GD::Image(); #put something on image... been using both clean GD synopsis and some home cooked small widgets. print $image->png; #or $m->out( $image->png ); #or $r->print( $image->png ); $m->content_type( "text/html" ); </%perl> Some more html text. </body> </html> Very simplified, but I don't have my code in front of me - sorry. I would assume that content_type in only good for setting in the header, but I don't see how I can mix in this PNG then. If GD could virtualle create a file I guess <img src="<% $image->png %>"> would work... but that seems like a long shot when reading the man for GD :) Any help/hints will be greatly appriciate. Maybe I just need to look harder for more ressources, but I've already spent a lot of time on something that looks quite simple - but haven't shown results yet. Best regards Nicolai Schlenzig nicolai.schlenzig(at)got2get.net