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();

In reply to Re: GD::Graph in HTML by kryberg
in thread GD::Graph in HTML by cosmicsoup

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.