Error in using GD Image

K

kd

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
 
B

Bob Walton

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?
 
G

Gregory Toomey

kd said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top