I am trying to generate dynamic pngs with Mason, like the photo gallery article on perl.com.
I'm trying to get the simple bits working before folding in the full application logic, so for now, I'm just trying to use a dhandler to server a red square for any file requests ending in .png in a certain directory. (That directory has no real png files.)
The dhandler looks like this:
and the directory in question is set to use Mason on .png files.<%shared> return unless $r->uri =~ /\.png$/; # die "made it here!"; use GD; my $image = new GD::Image(100, 100); my $red = $image->colorAllocate( 255, 0, 0); $image->filledRectangle( 25, 25, 75, 75, $red); $m->clear_buffer; $r->content_type('image/png'); $m->print($image->png); $m->abort(200); </%shared>
The dhandler is running, as I can reach the die message (by uncommenting that line).
But no image is displayed: firefox displays the file name requested (whatever.png); IE shows a broken image.
The related Mason book example on "generating something besides html" mentions $r->send_http_header, which I seems to be an Apache1.x-ism. I'm using Apache 2, which I suspect is relevant. The Apache2.x docs seem to imply that $r->send_http_header isn't necessary, that is, that just calling $r->content_type is sufficient.
In short, I'm not getting my red square.
I am not sure if my error is Mason or Apache or what.
Any ideas, wise monks?
Thanks!
In reply to Generating pngs with Mason by water
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |