#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 graph 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 into 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; #### print STDOUT $query->header(-type=>'image/png'); binmode STDOUT; print STDOUT $image->png();