Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Rendering of SVG content with GD into PNG file

by cosimo (Hermit)
on Feb 08, 2006 at 13:43 UTC ( [id://528794]=perlquestion: print w/replies, xml ) Need Help??

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

Hello monks,

I'm willing to write (and release to CPAN) a new class that can take as input an SVG text stream and output a PNG image. Something like:

use GD::Something; # maybe GD::SVG::Render? my $image = GD::Something->new(400, 300); $image->render('/my/file.svg'); print $image->png();

Today I fired a i /SVG/ query on my CPAN shell, but everything I found was related to GD -> SVG conversion.

I'd clearly prefer direct browser rendering of SVG, but as of Feb 2006, only Firefox 1.5 supports it without plugins, and the majority of our users is still using MS Internet Exploder.

So, before inventing my own wheel, is there some Perl class that is able to convert (even with some limits) an SVG text file to a PNG?

Thank you.

Replies are listed 'Best First'.
Re: Rendering of SVG content with GD into PNG file
by Anonymous Monk on Feb 08, 2006 at 14:18 UTC
Re: Rendering of SVG content with GD into PNG file
by zentara (Archbishop) on Feb 08, 2006 at 16:41 UTC
    Hi, I just posted an example SVG viewer for Perl/Gtk2 in which Gtk2 can load and display an SVG file. Now once it's loaded and sized, you can probably can work out a way to save the pixbuf as a png or jpg. Or you could use imageMagick's import to capture the window. Of course, this requires you have X running.

    You could also look at libsvg, and maybe make a Perl interface to it?


    I'm not really a human, but I play one on earth. flash japh

      Thank you guys for your suggestions, but I realized I need to clarify a bit what I'm doing.

      What I'm trying to achieve is creating a new blank GD::Image and draw inside it with all the (already existing) graphics primitives of GD. One (or more) of these drawing operations should render SVG text "documents" onto the existing GD::Image.

      I'd like to mix and match classic GD drawing (line, rectangle, filledRectangle, ...) with SVG drawing (ex.: $gdImage->svgDraw($svgtext)).

      This should be good to "prepare the way" to SVG. I mean, when (and only God knows) Internet Explorer will have SVG support, we could directly render into SVG, because all the underlying data is already in that format.

      Nevertheless, I'm going to take a closer look at your example (++), at Image::Magick's SVG features and libsvg, which are all quite interesting.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-26 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found