generate only single svg file
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 14 Aug 2010 12:42:44 +0000 (14:42 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 14 Aug 2010 12:42:44 +0000 (14:42 +0200)
unfortunatly, png export from inkscape always dumps all visible layers,
so front and back renderings are not correct

inkscape-render.pl

index 3fd33bd..b8e7360 100755 (executable)
@@ -6,6 +6,8 @@ use autodie;
 
 my $card_svg = 'card/ffzg-2010.svg';
 
+warn "# card template: $card_svg\n";
+
 my ($nr,$ime,$prezime) = ( qw/
 200900000042
 Dobrica
@@ -30,45 +32,40 @@ foreach my $existing ( glob $out . '*' ) {
        unlink $existing;
 }
 
-open(my $in,     '<', $card_svg);
-open(my $print,  '>', "$out.print.svg");
-open(my $screen, '>', "$out.screen.svg");
+open(my $svg_template, '<', $card_svg);
+open(my $svg,          '>', "$out.svg");
 
-while(<$in>) {
+while(<$svg_template>) {
 
        if ( m{($re)} ) {
                warn "mapping $1\n";
                s{($1)}{mapping($1)}e;
        }
 
-       if ( s{##print##}{none} ) {
-               warn "print layer: $_\n";
-               print $print $_;
-               s{none}{inline};
-               print $screen $_;
-
-       } else {
-               print $print  $_;
-               print $screen $_;
-       }
+       print $svg $_;
 
 }
 
-close($in);
-close($print);
-close($screen);
+close($svg_template);
+close($svg);
 
 open(my $inkscape, '|-', 'inkscape --shell --without-gui');
 
 sub inkscape_export {
        my $part = shift;
-       print $inkscape "$out.print.svg --export-area-page --export-pdf $out.$part.pdf --export-id $part\n";
-       print $inkscape "$out.screen.svg --export-png $out.png --export-dpi 300";
+
+       my $shell = "$out.svg --export-area-page --export-id $part";
+
+       print $inkscape "$shell --export-pdf $out.$part.pdf\n";
+       print $inkscape "$shell --export-png $out.$part.png --export-dpi 150\n";
 }
 
 inkscape_export 'print-front';
 inkscape_export 'print-back';
 
+# export visible
+print $inkscape "$out.svg --export-png $out.png --export-dpi 300\n";
+
 close($inkscape);
 
 __END__