Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Pretty graphics generation

by oakbox (Chaplain)
on Aug 02, 2004 at 01:37 UTC ( #379166=perlmeditation: print w/replies, xml ) Need Help??

I've spent a lot of frustrating time trying to find the 'best' way to create pretty graphics from data in my perl programs.

Spent a lot of time with GD.pm, it has a lot of easy-to-use modules built around it, but the graphics are always strongly aliased. There are tricks to lessen the aliasing, but nothing is perfect: Always a lot of hassle, no matter how much tweaking you do.

At one point, I looked at using POV-Ray files. POV-Ray graphing example Generating the text format file in perl, then doing a not-so-quick system call to ask POV-Ray to render the image for me. This was slow and 3-d only works for a limited range of information graphics.

I'm writing this because I'm bursting at the seams with excitement because I HAVE FOUND THE ANSWER: generating SVG files and using ImageMagik to convert those into whatever else you want (png,jpg,pdf,etc). SVG uses XML files and the syntax isn't overly weird. I started out using a WYSIWYG vector graphic program that exports SVG code http://www.sodipodi.com/, then manipulating the code in perl to produce what I was looking for. Mind you, as with most WYSIWYG's, I was able to reduce the auto-generated code by over 80%. But I learn better by having an example and tweaking it.

To introduce you to the joys of this format, if you are unfamiliar with it; here's an example graphic produced by running a perl-generated svg file through convert via a system call: http://www.oakbox.com/svg2png.png

And here is the svg file: http://www.oakbox.com/svg2png.svg.

And I get all this goodness by running
 system(convert svg2png.svg svg2png.png);

So, to sum up:
SVG + ImageMagick = Happiness

Replies are listed 'Best First'.
Re: Pretty graphics generation
by TVSET (Chaplain) on Aug 02, 2004 at 01:58 UTC
      I am converting sample.svg to samle.png using system(convert sample.svg sample.png). But the output png file is in full black color. Please help me Sharath
Re: Pretty graphics generation
by Anonymous Monk on Aug 02, 2004 at 20:04 UTC
Re: Pretty graphics generation
by Velaki (Chaplain) on Aug 04, 2004 at 12:44 UTC

    I've done some work with pulling config data from databases, and then using povray to generate scads of images for a few companies. Not the fastest, but decent.

    In my spare time, I've been working on adapting povray source to XS, so I can build modules, and then a mod_perl module / mod_pov for apache. It would be nice to have slightly faster semi-real-time raytracing going on. If you want faster, you go for scanline rendering, like blender. The quality isn't as good, but for basic graphs, it's pretty clever.

    -v
    "Perl. There is no substitute."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://379166]
Front-paged by Anneq
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2020-03-29 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (171 votes). Check out past polls.

    Notices?