Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

PNG Images.

Quote Reply
PNG Images.
Hey,

You guys here are pretty smart, so I am guessing you may now where I can find out how to use Perl to create PNG images...

I am trying to make some graphs with Perl, and just using the <hr> tag with the width attribute determinded by the script works, but doesn't look that good.

Anyone know??? Thanks!

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: PNG Images. In reply to
Hi!

You want to use the GD module, and I'd recommend getting a charting module as well. You can find it at:

Chart: http://www.perl.com/...PNGgraph-1.15.tar.gz
GD: http://www.perl.com/...le/GD/GD-1.23.tar.gz

Cheers,

Alex
Quote Reply
Re: PNG Images. In reply to
 http://www.pdamania.com/graph.cgi?ID=1002

part of review.cgi v2

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: PNG Images. In reply to
Jerry,

Would it possible for you to send me the code for graph.cgi, I want to find out how to use PNG images. - Also, do I need to install any modules on my server for it to work?

Thanks!

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: PNG Images. In reply to
Argh, I didn't see your post Alex Wink - Is that all the modules I will need to get ONG images going...

BTW, is it just a case of plotting heaps of (x,y) corrdinates??? Thanks!

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: PNG Images. In reply to
michael.. sorta...

but you can draw shapes... so it's faster.. u can get images from other places and paste it on there too..there are some mods that basically act like a DBSQL.pm to GD.pm.. like you can say..

$img1 = new PortGD "/path/to/image.gif";
$sratch = $img1 cut(0,0,100,100);

instead of creating objects over and over..

------------------
Jerry Su
Links SQL User
------------------
Quote Reply
Re: PNG Images. In reply to
Sounds good. Do you know where I could find some documentation on how to use it? The readme file from CPAN doesn't really help Smile

Cause...

(0,0,100,100);

My understanding as always been things are on an axis - (x,y) with with x being horizontal and y being vertical, and having z for 3 dimensional grids (which gets complicated...)

I am sure once I get some instructions on how to use it I'll be right Smile

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: PNG Images. In reply to
Hmmm...

(0,0) - (100,100)
x1 y1 x2 y2

Wouldn't that be a 45 degree line?

Argh - I never was good at coordinate geometry!

------------------
Michael Bray
Review your webhost or find a new one.
www.webhostarea.com
Links SQL User
------------------




Quote Reply
Re: PNG Images. In reply to
If you are creating charts it's much easier. Say you want a bar chart, then you just need two arrays of x and y values and do:

my $img = $chart->png ("mygraph.png", [ @x_values, @y_values] );

and it's done. You can of course do things like setting labels, colours, etc, but to just do a quick graph that's all there is to it. Install Chart and GD (if you are on windows, use ppm, they are already there). Then just type:

perldoc Chart

for a how-to.

Cheers,

Alex
Quote Reply
Re: PNG Images. In reply to
I believe the (0,0,100,100) refers to (x1,y1,x2,y2) in order to map out a region. So in the example given, the region mapped corresponds from top left corner (0,0) to bottom right corner (100,100) - in other words, a square with sides equal to 100 pixels.

Dan Smile