in reply to GD::Graph in HTML

Here's a snippet of some code where I did something similar:
#plot data to a png graph # I have a temporary image because I end up splicing # two images together open(GRAPH, "+>./supportfiles/temp.png") or die("Cannot open temp grap +h file: $!") ; my $gd = $graph->plot($data) or die $graph->error; binmode GRAPH; print GRAPH $gd->png; seek GRAPH, 0, 0; my $gdgraph = newFromPng GD::Image(\*GRAPH) or die ("Cannot read into +GD object: $ !" ); close GRAPH; # second, pre-existing image I supperimpose on the first open(LOGO, "<./supportfiles/logo.png") or die("Cannot open logo file: +$!" ); my $image = newFromPng GD::Image(\*LOGO) or die ("Cannot read logo int +o GD object: $!" ); $gdgraph->colorAllocate(255,255,255); $gdgraph->copy($image,460,368,0,0,80,22); # File name for final image my $filename = "$number" . "_" . "$huc" . ".png"; open(IMG, ">./charts/$filename") or die $!; binmode IMG; print IMG $gdgraph->png;
You can actually do this dynamically with perl and HTML and not save an actual file. It all has to do with the binmode. If you want to do it dynamically, expermient with something like:
print STDOUT $query->header(-type=>'image/png'); binmode STDOUT; print STDOUT $image->png();