bret.foreman has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting the picture
by gaal (Parson) on Aug 11, 2004 at 16:45 UTC | |
by bret.foreman (Acolyte) on Aug 11, 2004 at 17:15 UTC | |
by gaal (Parson) on Aug 11, 2004 at 17:26 UTC | |
by sgifford (Prior) on Aug 11, 2004 at 19:26 UTC | |
|
Re: Getting the picture
by davorg (Chancellor) on Aug 11, 2004 at 16:37 UTC | |
by bret.foreman (Acolyte) on Aug 11, 2004 at 17:03 UTC | |
|
Re: Getting the picture
by CountZero (Bishop) on Aug 11, 2004 at 18:49 UTC | |
|
Re: Getting the picture
by ikegami (Patriarch) on Aug 11, 2004 at 17:42 UTC | |
|
Re: Getting the picture
by eserte (Deacon) on Aug 11, 2004 at 18:20 UTC | |
|
Re: Getting the picture
by jaco (Pilgrim) on Aug 11, 2004 at 16:54 UTC | |
by bret.foreman (Acolyte) on Aug 11, 2004 at 17:16 UTC |