Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

GDGraph Installation

by Lhamo_rin (Friar)
on Aug 30, 2005 at 16:42 UTC ( [id://487835]=perlquestion: print w/replies, xml ) Need Help??

Lhamo_rin has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I have installed GD and GD::Graph along with the required zlib and libpng. When running a simple script I get the following error:

Can't locate object method "png" via package "GD:;Image" at ./gd_test2.pl line 33.

Can someone explain why I might get this message?

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->png;

Replies are listed 'Best First'.
Re: GDGraph Installation
by Tanktalus (Canon) on Aug 30, 2005 at 17:46 UTC
    $ perl -we 'print $im->png' Name "main::im" used only once: possible typo at -e line 1. Can't call method "png" on an undefined value at -e line 1.

    I think I need a bit more code to replicate the same problem as you're having. ;-)

Re: GDGraph Installation
by Fang (Pilgrim) on Aug 30, 2005 at 17:48 UTC

    Paste the whole code instead of only the line causing trouble.

    When you installed GD, did it correctly detect libpng? Did it tell you explicitely that PNG support was enabled?

    Update (after Lhamo_rin posted the full code): this is the example code from the GD doc, it works perfectly on my system, so I guess your issue has to do with how you installed all the needed libs. As johnnywang suggested, now that libpng is installed, recompile libgd, then reinstall GD.

Re: GDGraph Installation
by johnnywang (Priest) on Aug 30, 2005 at 18:01 UTC
    The code itself runs ok on my system. I'm thinking may be you need to install libpng before libgd and GD module? I did them in that order, didn't need to do any special configuration or flags.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://487835]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-18 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found