The start of my cgi puts up an h2 header and a scrolling menu where the user selects a dataset file, then clicks a "show me" button and then I want a graph to appear, either in the same window below the menu or in a new window - I don't care which.
I use open3 to launch gnuplot in a mode where it accepts commands and data in stdin, sends errors to stderr, and sends the image to stdout. (Please no warnings about deadlocks with open3, I know all about that.) So my PNG image ends up in a file handle returned by open3, which I'll call $png_image_fh. This all works fine and an examination of the PNG data looks apparantly correct, though we won't know until I can actually display it as an image.
Now, I need to read the data from the $png_image_fh and print it out as a PNG image. Looking around in the perlmonk faq, I found this thread: http://www.perlmonks.com/index.pl?node_id=18565 from which I generated the following code:
Instead of an image, what I get is the PNG data printed in text mode. Any ideas why this might be? The server is Linux, the browser is IE 6.my ($image_buf,$chunk); while ( read( $png_image_fh , $chunk , 1024 ) ) { $image_buf .= $chunk; } print "Content-type: image/png\n\n"; # binmode included in case we run on Windoze binmode STDOUT; print $image_buf;
Thanks
Bret
In reply to Getting the picture by bret.foreman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |