graph problem

Discussion in 'Perl Misc' started by Sokar, Mar 22, 2005.

  1. Sokar

    Sokar Guest

    Hello,

    I have a script which creates a pie chart from the following lines of code:

    my @values = (["$val1", "$val2", "$val3", "$val4"],
    [$var1, $var2, $var3, $var4]);

    my $graph = GD::Graph::pie->new(300, 300);
    $graph->set(
    title => "Status of students for
    year: $year",
    '3d' => 1,
    ) or warn $graph->error;

    my $image = $graph->plot(\@values) or die "cant print graph\n";

    open(IMG, ">pie1.jpeg") or die $!;
    binmode IMG;
    print $image->jpeg;
    close IMG;

    This bit of code actually creates a jpeg and stores it on the hard drive.
    What I am looking to do is actually create the graph and then e-mail it to a
    person. I was wondering if anyone knew how I could maybe instead of writing
    the graph into an actual jpeg, write it into a variable and then e-mail the
    variable as a jpeg to an e-mail address, to save me having the created jpegs
    sitting on my hard drive.

    Thanks and regards

    John
    Sokar, Mar 22, 2005
    #1
    1. Advertising

  2. Sokar

    Octo Mancer Guest

    On Tue, 22 Mar 2005 14:43:40 +0000, Sokar wrote:

    <SNIP>
    >
    > open(IMG, ">pie1.jpeg") or die $!;
    > binmode IMG;
    > print $image->jpeg;


    ITYM

    print IMG $image->jpeg;

    > close IMG;
    >
    > This bit of code actually creates a jpeg and stores it on the hard drive.
    > What I am looking to do is actually create the graph and then e-mail it to
    > a person. I was wondering if anyone knew how I could maybe instead of
    > writing the graph into an actual jpeg, write it into a variable and then
    > e-mail the variable as a jpeg to an e-mail address, to save me having the
    > created jpegs sitting on my hard drive.


    Use IO::Scalar (code untested):

    my $img;
    my $imgScalar = IO::Scalar->new(\$img);
    print $imgScalar $image->jpeg;

    HTH
    Rich
    Octo Mancer, Mar 22, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Sakkis
    Replies:
    1
    Views:
    434
    Szabolcs Nagy
    Jan 29, 2007
  2. Dr Ann Huxtable

    Missing Graph.h and (Graph.lib) woes - any help

    Dr Ann Huxtable, Dec 21, 2004, in forum: C Programming
    Replies:
    6
    Views:
    627
    Dr Ann Huxtable
    Dec 21, 2004
  3. Jef Driesen
    Replies:
    3
    Views:
    2,527
    mlimber
    Jan 24, 2006
  4. Almoni
    Replies:
    0
    Views:
    3,084
    Almoni
    Jan 17, 2010
  5. Emilio Mayorga
    Replies:
    6
    Views:
    314
    Martien Verbruggen
    Oct 8, 2003
Loading...

Share This Page