Use Gtk2's SVG library. Then you can load the svg as a pixbuf, and manipulate, slice and dice, and convert to png. Here is a start. This autoresizes the svg when you resize the window.
#!/usr/bin/perl use warnings; use strict; use Glib qw(TRUE FALSE); use Gnome2::Rsvg; Gtk2->init; my $img; my $mw = Gtk2::Window->new; $mw->signal_connect (delete_event => sub { Gtk2->main_quit }); my $vbox = Gtk2::VBox->new (FALSE, 4); $vbox->set_border_width (4); $vbox->show; # Create the main box my $vp = Gtk2::Viewport->new(undef, undef); # Layout the stuff $vbox->pack_start ($vp, TRUE, TRUE, 0); $vp->show; $mw->add( $vbox ); get_svg(400,400); $mw->signal_connect (event_after => \&event_after); #$mw->add_events ([qw/ button-press-mask # button-release-mask # key-release-mask # /]); #$mw->signal_connect('button-release-event' => sub { # my ($widget,$event) = @_; # #count is in the same namespace as the closure # print "release\n"; # }); #$mw->signal_connect (event => sub { # my ($item, $event) = @_; # warn "event ".$event->type."\n"; #return FALSE; #}); #$mw->signal_connect (realize => sub { #$window->move ($pos->{x}, $pos->{y}); #$window->resize ($pos->{width}, $pos->{height}); # print "1\n"; #}); $mw->show; Gtk2->main; ################################################3 sub get_svg { my ($x,$y) = @_; $vp->remove($img) if defined $img; my $file = 'svg.svg'; my $pb = Gnome2::Rsvg->pixbuf_from_file_at_zoom_with_max($file,15, +15,$x,$y); # ($file, x_zoom, y_zoom, max_x, max_y ) $img = Gtk2::Image->new_from_pixbuf($pb); #($x, $y) = ($pb->get_width, $pb->get_height); $vp->add($img); $img->show; #will auto expand ???? #$vp->set_size_request($x,$y); $vp->set_size_request(.9*$x,.9*$y); $vp->show; } ############################################ sub event_after { my ($mw, $event) = @_; return FALSE unless $event->type eq 'configure'; # print $event->type,"\n"; #return FALSE unless $event->button == 1; my ($x, $y) = $mw->get_size; print "$x $y\n"; get_svg($x,$y); return FALSE; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku

In reply to Re: SVG to many PNG problem by zentara
in thread SVG to many PNG problem by stabu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.