in reply to Re: Qestion about GD::SecurityImage
in thread Qestion about GD::SecurityImage

Thanks for your reply. I follow the instruction and run the demo.pl as a CGI program successfully except the image does not show up (only see its alt string). Then I try this GD test code :
use GD; # create a new image $im = new GD::Image( 100, 100 ); # allocate some colors $white = $im->colorAllocate( 255, 255, 255 ); $black = $im->colorAllocate( 0, 0, 0 ); $red = $im->colorAllocate( 255, 0, 0 ); $blue = $im->colorAllocate( 0, 0, 255 ); # make the background transparent and interlaced $im->transparent($white); $im->interlaced('true'); # Put a black frame around the picture $im->rectangle( 0, 0, 99, 99, $black ); # Draw a blue oval $im->arc( 50, 50, 95, 75, 0, 360, $blue ); # And fill it with red $im->fill( 50, 50, $red ); # make sure we are writing to a binary stream binmode STDOUT; # Convert the image to PNG and print it on standard output print $im->jpeg;
And then I got a error message like this:
[cmo@fedora ~]$ perl gdtest.pl > test.jpeg Can't locate object method "jpeg" via package "GD::Image" at gdtest.pl + line 29.
line 29 is "print $im->jpeg;". GD::Image is installed successfully but Why this error happen?

Thanks again.

Replies are listed 'Best First'.
Re^3: Qestion about GD::SecurityImage
by marto (Cardinal) on Jan 29, 2010 at 10:40 UTC

    Did you install the JPEG library prior to installing as described in the README?

      Hi, I already installed jpegsrc.v6b.tar.gz like the following but still see the image's alt 'Security Image' only. Is there anywhere else I can check?
      [abc@fedora jpeg-6b]$ sudo make install /usr/bin/install -c cjpeg /usr/local/bin/cjpeg /usr/bin/install -c djpeg /usr/local/bin/djpeg /usr/bin/install -c jpegtran /usr/local/bin/jpegtran /usr/bin/install -c rdjpgcom /usr/local/bin/rdjpgcom /usr/bin/install -c wrjpgcom /usr/local/bin/wrjpgcom /usr/bin/install -c -m 644 ./cjpeg.1 /usr/local/man/man1/cjpeg.1 /usr/bin/install -c -m 644 ./djpeg.1 /usr/local/man/man1/djpeg.1 /usr/bin/install -c -m 644 ./jpegtran.1 /usr/local/man/man1/jpegtran.1 /usr/bin/install -c -m 644 ./rdjpgcom.1 /usr/local/man/man1/rdjpgcom.1 /usr/bin/install -c -m 644 ./wrjpgcom.1 /usr/local/man/man1/wrjpgcom.1
      I also checked mysql table like this:
      mysql> select * from sessions; +----------------------------------+---------------------------------- +-------------------------------------------------+ | id | a_session + | +----------------------------------+---------------------------------- +-------------------------------------------------+ | e6a5ed9dd1afc80ad115097e97ea7e5c |   e6a5ed9dd1afc80ad115097e97ea7e5c _session_id security_code | | abe1ec864cf636ea147b8982331fc211 |   abe1ec864cf636ea147b8982331fc211 _session_id security_code | | 4a926009da58be40afdad7baef41d9e4 |   4a926009da58be40afdad7baef41d9e4 _session_id security_code | | 7a65f897282e294c9153892395dfe84c |   7a65f897282e294c9153892395dfe84c _session_id security_code | +----------------------------------+---------------------------------- +-------------------------------------------------+ 4 rows in set (0.00 sec)
      BTW, I noticed there are totally three items in the OPTIONAL section for Linux INSTALLATION from the README file. Are they all necessary to run demo.pl ? Thanks.
      (OPTIONAL) The FreeType font rendering library for TrueType fonts. The JPEG library, version 6b or later The XPM library,
      And perl gdtest.pl > test.jpeg still does not work.

        Rather than just randomly trying things you need to learn to read the documentation. For example, you failed to read the GD documentation informing you about installing libjjpeg. The documentation I think is pretty clear.

        To answer your multiple post, you don't need to install XPM or FreeType (or libjpeg for that matter) to build GD, which is why they are marked at optional. If you don't know what these things are, do some research on them and decide wither you should install them or not.

        My advice to you is:

        • Read the libgd Compile FAQ, download and compile the prerequisites.
        • (Re)Build libgd.
        • Re install the GD perl module, reading and understanding the README before hand.
        • Try some of the tests which ship as part of the distribution.
        • If you have any further problems, compose your thoughts and post a single reply, rather than multiple short replies in quick succession.

        Martin

Re^3: Qestion about GD::SecurityImage
by stefbv (Priest) on Jan 29, 2010 at 10:51 UTC
    Also check the version of GD, only newer versions support jpeg.
      Hi, The GD version is 2.44.