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

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I'm trying to execute this Perl simple script:
use GD;
my $srcimage = GD::Image->newFromJpeg("image_news.jpg");
my ($srcW,$srcH) = $srcimage->getBounds();

But I get this error message:
Can't locate object method "newFromJpeg" via package "GD::Image" at
../ line 3.

I've got GD and libgd compiled with JPEG support turned on.

1) JPEG libs
  + Downloaded from
  + mkdir /usr/local/jpeg-6b
  + mkdir /usr/local/jpeg-6b/bin
  + mkdir /usr/local/jpeg-6b/man
  + mkdir /usr/local/jpeg-6b/man/man1
  + mkdir /usr/local/jpeg-6b/incude
  + mkdir /usr/local/jpeg-6b/lib
  + ./configure --prefix=/usr/local/jpeg-6b --enable-shared
  + make
  + make test
  + make install

2) libgd
  + Downloaded from /
  + mkdir /usr/local/gd
  + ./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg-6b
  + make
  + make install

3) GD-Perl
  + Downloaded from
  + export
  + perl Makefile.PL GD_JPEG -lib_gd_path /usr/local/gd -lib_jpeg_path
/usr/local/jpeg-6b -lib_zlib_path /usr/local/zlib
Included Features:          GD_JPEG GD_FREETYPE GD_PNG GD_GIF
GD library used from:       /usr/local/gd
JPEG library used from:      /usr/local/jpeg-6b
Zlib library used from:     /usr/local/zlib
Checking if your kit is complete...
Looks good
Writing Makefile for GD
  + make
gcc -c  -I/usr/local/zlib/include -I/usr/local/jpeg-6b/include
-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g
-pipe -m32 -march=i386 -mtune=pentium4   -DVERSION=\"2.30\"
-DXS_VERSION=\"2.30\" -fPIC
"-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE"  -DHAVE_JPEG
gcc  -shared -L/usr/local/lib GD.o  -o blib/arch/auto/GD/
-L/usr/local/zlib/lib -L/usr/local/jpeg-6b/lib -L/usr/local/lib
-L/usr/local/lib -L/usr/local/lib -ljpeg -lfreetype -lpng12 -lz -lm
Manifying blib/man1/
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
  + make install
Files found in blib/arch: installing files in blib/lib into
architecture dependent library tree
installation info to

Within '/etc/':

What am I doing wrong? Thank you very much.

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

Quoted text here. Click to load it

That's puzzling. You're script works fine for me with version 2.23. Does
version 2.30 still define a 'newFromJpeg' sub ? (I would think it does. The
documentation claims that it does.)

Are there any other versions of GD installed ?

It might pay to check that you are, in fact, running version 2.30:

use GD;
print $GD::VERSION, "\n";


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

Sisyphus wrote:
Quoted text here. Click to load it

Yes, I'm using 2.30.
How can I check if I've got other versions of GD installed? It may be,
cause I've
been doing several tests with several versions.

Quoted text here. Click to load it

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

Quoted text here. Click to load it

If the above script is reporting '2.30' then that's the version of GD that's
being found.

I just installed version 2.30 on my Win32 box and the script you posted
still works fine. However, I found that if I build GD-2.30 *without* jpeg
support, then I get an error very similar to yours when I run the script you
originally posted. I get:

Can't locate object method "_newFromJpeg" via package "GD::Image" at
D:/perl58_M/site/5.8.7/lib/GD/ line 185.

Essentially there are 2 differences:
1) for me, the object method "_newFromJpeg" is not found, whereas your error
reported that the object method "newFromJpeg" is not found;
2) my error is reported in, whereas yours was reported in the

I'm starting to think that, although you *think* your GD-2.30 was built with
jpeg support, perhaps it wasn't. However, when I look at the output you
posted originally, it looks to me that your GD-2.30 *was* built with jpeg

Did you specify 'y' at all of the prompts when 'perl Makefile.PL' was run ?
It might be informative to find out which subtests were skipped. Try

perl -Mblib t\GD.t


perl -Mblib t\Polyline.t

However .... basically, I'm stumped by this - and am hoping that someone
that actually *knows* what has gone wrong comes forward :-)

Perhaps Google will turn up an answer for you .... or you might have to
contact the author if all else fails.


Site Timeline