Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't locate object method "newFromJpeg" via package "GD::Image&q

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
Hi.

I'm trying to execute this piece of code:
----------
#!/usr/bin/perl
use GD;
my $srcimage = GD::Image->newFromJpeg("/home/john/dog.jpg");
my ($srcW,$srcH) = $srcimage->getBounds();
--------------

And I get this message error:
---------------
Can't locate object method "newFromJpeg" via package "GD::Image" at test.pl line 3.
---------------

My configuration is made with the last versions of:

I had no problems to build GD-2.30:

[] perl Makefile.PL
---------
Checking if your kit is complete...
Looks good
Writing Makefile for GD
-----------
[] make
-------------------
Manifying blib/man1/bdf2gdfont.pl.1
Manifying blib/man3/GD::polyline.3pm
Manifying blib/man3/GD::Image.3pm
Manifying blib/man3/GD::Simple.3pm
Manifying blib/man3/GD.3pm
Manifying blib/man3/GD::polygon.3pm
--------------------
[] make test
---------------------
All tests successful, 3 subtests skipped.
Files=2, Tests=13, 1 wallclock secs ( 0.22 cusr + 0.03 csys = 0.25 CPU)
--------------------
[] make install
---------------------
Installing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/GD/GD.so
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Writing /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/GD/.packlistAppending installation info to /usr/lib/perl5/5.8.5/i386-linux-thread-multi/perllocal.pod
----------------------

What am I doing wrong? Thank you very much.
 
My docs for GD don't list newFromJpg as a method. They offer
Code:
Object Constructors: Creating Images
       The following class methods allow you to create new GD::Image objects.

       $image = GD::Image->new([$width,$height],[$truecolor])
       $image = GD::Image->new(*FILEHANDLE)
       $image = GD::Image->new($filename)
       $image = GD::Image->new($data)
of which the third looks appropriate.

Are you using the right docs for your installed version?

Yours,

fish

["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.["]
--Maur
 
I'm have GD 2.30 installed and it does list that method:
$image = GD::Image->newFromPng($file, [$truecolor])
$image = GD::Image->newFromPngData($data, [$truecolor])
The newFromPng() method will create an image from a PNG file read in
through the provided filehandle or file path. The filehandle must
previously have been opened on a valid PNG file or pipe. If
successful, this call will return an initialized image which you can
then manipulate as you please. If it fails, which usually happens if
the thing at the other end of the filehandle is not a valid PNG
file, the call returns undef. Notice that the call doesn't
automatically close the filehandle for you. But it does call
"binmode(FILEHANDLE)" for you, on platforms where this matters.

So, like fish asked, do the docs refer to the version of GD you're using?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top