I seem to be having a problem with Image::Magick in Mason. The following code works great at a CGI script:
#!/usr/bin/perl use strict; use Image::Magick; $| = 1; my $image = Image::Magick->new; $image->Set (size => '500x750'); $image->Read ('xc:black'); print "Content-Type: image/png\n\n"; binmode STDOUT; $image->Write ('png:-'); exit 0;
Notice that I'm turning off buffering ($| = 1) and using the Write() routine to go to STDOUT.
Now, when I do this in Mason:
<%perl> use Image::Magick; $| = 1; my $image = Image::Magick->new; $image->Set (size => '500 x 750'); $image->Read ('xc:black'); $m->clear_buffer; $r->content_type ('image/png'); $image->Write ('png:-'); $m->abort; </%perl>
I get nothing sent to the browser but the header. I'm assuming that the Write() that Image::Magick is using is somehow bypassing the Mason mechanisms here. I've tried sprinkling $m->flush_buffer around too, but to no effect.
How is Mason handling STDOUT and how is Image::Magick? I'd like to see if I could get Mason working with it. Otherwise, I should be able to create a temporary .PNG and then feed it out to STDOUT manually (although I've yet to be successful creating a .PNG from Mason using Image::Magick either). But I assume that's some sort of file security problem.
THANKS for any and all hints and tips that you can provide. I know we're all very busy so it's TRULY appreciated!
In reply to Image::Magick in Mason and STDOUT by eugeneman42
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |