Error in using GD Image

Discussion in 'Perl Misc' started by kd, Jul 30, 2005.

  1. kd

    kd Guest

    Hi all,


    I am a new member of this group. I have a program that uses GD
    for drawing objects on images.I have the image in the cgi-bin directory
    itself.I would be happy if someone in the group could help me out with
    this.Thanks in advance.


    Here is the code I wrote :


    #!/usr/bin/perl
    use strict;
    use GD;
    use GD::polyline;
    use Math::Trig;
    use Math::Round;
    use CGI;


    my $map = newFromPng GD::Image('Overview.png');
    print "Content-type: image/png\n\n";
    binmode STDOUT;
    print $map->png;


    Error :
    Can't call method "png" on an undefined value at ./check.cgi line 12.


    -
    Karthik
    kd, Jul 30, 2005
    #1
    1. Advertising

  2. kd

    Bob Walton Guest

    kd wrote:

    ....
    > I am a new member of this group. I have a program that uses GD
    > for drawing objects on images.I have the image in the cgi-bin directory
    > itself.I would be happy if someone in the group could help me out with
    > this.Thanks in advance.
    >
    >
    > Here is the code I wrote :
    >
    >
    > #!/usr/bin/perl
    > use strict;
    > use GD;
    > use GD::polyline;
    > use Math::Trig;
    > use Math::Round;
    > use CGI;
    >
    >
    > my $map = newFromPng GD::Image('Overview.png');


    You should check here to see if ->newFromPng succeeded or not.
    Sounds like it probably didn't, and that that is the source of
    your problem. Note that the probable reason for this is that
    when your web server runs your CGI script, your script's current
    directory isn't set to where you seem to think it is. Look in
    your server documentation for where the CGI script's directory is
    pointed (or write a simple test script to print it out). Note
    also that the user the script is running under may also not be
    who you think it is, and that that can cause permissions problems
    (assuming you are using a good OS).

    > print "Content-type: image/png\n\n";


    Why not use CGI's header() method to generate the header? It
    will do a better job. You "use CGI;" and then don't use any of
    its features -- why?

    > binmode STDOUT;
    > print $map->png;
    >
    >
    > Error :
    > Can't call method "png" on an undefined value at ./check.cgi line 12.
    >
    >
    > -
    > Karthik
    >

    --
    Bob Walton
    Email: http://bwalton.com/cgi-bin/emailbob.pl
    Bob Walton, Jul 30, 2005
    #2
    1. Advertising

  3. "kd" <> wrote in message
    news:...
    > Hi all,
    >
    >
    > I am a new member of this group. I have a program that uses GD
    > for drawing objects on images.I have the image in the cgi-bin directory
    > itself.I would be happy if someone in the group could help me out with
    > this.Thanks in advance.
    >
    >


    > Error :
    > Can't call method "png" on an undefined value at ./check.cgi line 12.


    You may be using an older version of GD. Try upgrading or write a gif
    instead.

    gtoomey
    Gregory Toomey, Aug 2, 2005
    #3
    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. Neo Geshel
    Replies:
    2
    Views:
    1,090
    Neo Geshel
    Jun 14, 2005
  2. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,248
    Kartic
    Jan 26, 2005
  3. pandiaraj_4u
    Replies:
    0
    Views:
    1,814
    pandiaraj_4u
    Apr 7, 2010
  4. Waverider
    Replies:
    1
    Views:
    187
    JuanDG
    Sep 21, 2004
  5. Jack
    Replies:
    2
    Views:
    203
    John W. Krahn
    Jan 25, 2008
Loading...

Share This Page