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

This is a discussion on Can't locate object method "newFromJpeg" via package "GD::Image" - Perl ; Hi. I'm trying to execute this Perl simple script: -------- #!/usr/bin/perl 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 ../test.pl line ...

+ Reply to Thread
Results 1 to 4 of 4

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

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

    Hi.

    I'm trying to execute this Perl simple script:
    --------
    #!/usr/bin/perl
    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
    ../test.pl line 3.
    -------

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


    1) JPEG libs
    + Downloaded from http://www.ijg.org/files/jpegsrc.v6b.tar.gz
    + 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 http://www.boutell.com/gd/http/
    + mkdir /usr/local/gd
    + ./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg-6b
    + make
    + make install

    3) GD-Perl
    + Downloaded from http://search.cpan.org/~lds/GD-2.30/
    + export
    LD_LIBRARY_PATH=/usr/local/lib:/usr/local/gd/lib:/usr/local/zlib/lib:/usr/local/jpeg-6b/lib:$LD_LIBRARY_PATH
    + 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_UNCLOSEDPOLY GD_ANIMGIF GD_FTCIRCLE VERSION_33
    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
    -I/usr/local/include -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
    -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
    -DHAVE_FT -DHAVE_GIF -DHAVE_PNG -DHAVE_ANIMGIF -DVERSION_33
    -DHAVE_UNCLOSEDPOLY -DHAVE_FTCIRCLE GD.c
    ....
    gcc -shared -L/usr/local/lib GD.o -o blib/arch/auto/GD/GD.so
    -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
    -lgd
    ....
    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
    ----------------------

    Within '/etc/ld.so.conf':
    --------
    /usr/local/gd/lib
    /usr/local/zlib/lib
    /usr/local/jpeg-6b/lib
    --------

    What am I doing wrong? Thank you very much.


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


    <francescomoi@usa.com> wrote in message
    news:1134990197.769908.282800@f14g2000cwb.googlegroups.com...
    > Hi.
    >
    > I'm trying to execute this Perl simple script:
    > --------
    > #!/usr/bin/perl
    > 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
    > ./test.pl line 3.
    > -------
    >


    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:

    #!/usr/bin/perl
    use GD;
    print $GD::VERSION, "\n";
    __END__

    Cheers,
    Rob



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


    Sisyphus wrote:
    >
    > 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:
    >
    > #!/usr/bin/perl
    > use GD;
    > print $GD::VERSION, "\n";
    > __END__


    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.


    >
    > Cheers,
    > Rob



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


    "Francesco Moi" <franscescomoi@usa.com>

    > >
    > > #!/usr/bin/perl
    > > use GD;
    > > print $GD::VERSION, "\n";
    > > __END__

    >
    > 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.


    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/Image.pm 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 Image.pm, whereas yours was reported in the
    script.

    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
    support.

    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
    running:

    perl -Mblib t\GD.t

    and:

    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.

    Cheers,
    Rob



+ Reply to Thread

Similar Threads

  1. Replies: 7
    Last Post: 12-13-2007, 02:44 PM
  2. "Can't locate object method "PV" via package "B::SPECIAL""
    By Application Development in forum Perl
    Replies: 3
    Last Post: 10-20-2007, 12:02 PM
  3. Can't locate object method "host" via package "URI::_foreign"
    By Application Development in forum Perl
    Replies: 1
    Last Post: 06-01-2007, 12:36 PM
  4. Can't locate object method "blocking" via package "IO::Handle"
    By Application Development in forum Perl
    Replies: 1
    Last Post: 06-20-2005, 09:54 AM
  5. GD::Image: Can't locate object method "newFromJpeg"
    By Application Development in forum Perl
    Replies: 1
    Last Post: 04-04-2005, 02:47 PM