chiark / gitweb /
Work around Inkscape command-line breaking change.
authorSimon Tatham <anakin@pobox.com>
Wed, 27 Oct 2021 17:29:18 +0000 (18:29 +0100)
committerSimon Tatham <anakin@pobox.com>
Wed, 27 Oct 2021 17:49:47 +0000 (18:49 +0100)
It looks as if Inkscape 1.0 changed the command-line syntax for
converting an SVG into a PNG, and didn't provide any syntax I can see
that works in both versions. Bodge around that with an initial run of
'inkscape --version', so that this package build should work both
before and after that breaking change.

resources/inkscape_export.pm [new file with mode: 0644]
resources/make-base-marble.pl
resources/make-pieces-marble.pl
resources/make-pieces-neon.pl
resources/make-pieces-zen.pl
resources/make-wall-marble.pl

diff --git a/resources/inkscape_export.pm b/resources/inkscape_export.pm
new file mode 100644 (file)
index 0000000..7e0545e
--- /dev/null
@@ -0,0 +1,13 @@
+our $inkscape_export_option = undef;
+
+sub inkscape_export {
+    my ($opts, $width, $height, $outfile, $infile) = @_;
+    unless (defined $inkscape_export_option) {
+        my $ver = `inkscape --version`;
+        $inkscape_export_option = ($ver =~ /Inkscape 0\./) ? "-e" : "-o";
+    }
+
+    system "inkscape $opts -w $width -h $height $inkscape_export_option $outfile $infile";
+}
+
+1;
index 6f4821cf7f8eb0c455d84ea0ca11084783fdd9ad..a20f078ece48440fe4a328a066092767dfe14512 100755 (executable)
@@ -21,6 +21,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+require './inkscape_export.pm';
+
 if($#ARGV != 1)
 {
     print STDERR "Usage: make-base-marble.pl <file.svg> <directory>\n";
@@ -69,5 +71,5 @@ sub make_pieces
     $background = "";
 
     # Use Inkscape to convert the SVG to a PNG
-    system("inkscape $background -w $width_png -h $height_png -e $file_png $file_svg");
+    inkscape_export($background, $width_png, $height_png, $file_png, $file_svg);
 }
index a4e3968fad7551b2d273df09e81edd9fa2560cad..e786bf96a672f4fcdd91272a4cc05305f53eaf18 100755 (executable)
@@ -21,6 +21,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+require './inkscape_export.pm';
+
 if($#ARGV != 1)
 {
     print STDERR "Usage: make-pieces-marble.pl <pieces.svg> <directory>\n";
@@ -88,7 +90,7 @@ sub make_pieces
     $background = "-b \"#000000\"" if($partial);
 
     # Use Inkscape to convert the SVG to a PNG
-    system("inkscape $background -w $width_png -h $height_png -e $file_png $file_svg");
+    inkscape_export($background, $width_png, $height_png, $file_png, $file_svg);
 
     for($piece = 0; $piece < $rows * $columns; $piece ++)
     {
index 7e8c29ea38a5bf025b6955289628bc240f559a9d..c9d6c676cf8c09af96ba7921c26b735286a652cd 100755 (executable)
@@ -34,6 +34,8 @@
 # Use blur-full for most pieces, blur-half for earth and earth_double, and
 # blur-quarter for earth_directional, maps and teleport.
 
+require './inkscape_export.pm';
+
 if($#ARGV != 0)
 {
     print STDERR "Usage: make-pieces-neon.pl <directory>\n";
@@ -96,13 +98,13 @@ sub make_pieces
     $height_png = $height * ($columns * 2 + 1);
 
     $file_png_base = "/tmp/chroma-pieces-base-$$.png";
-    system("inkscape -w $width_png -h $height_png -e $file_png_base $file_svg_base");
+    inkscape_export("", $width_png, $height_png, $file_png_base, $file_svg_base);
 
     $file_png_overlay = "/tmp/chroma-pieces-overlay-$$.png";
-    system("inkscape -w $width_png -h $height_png -e $file_png_overlay $file_svg_overlay");
+    inkscape_export("", $width_png, $height_png, $file_png_overlay, $file_svg_overlay);
 
     $file_png_overlay_double = "/tmp/chroma-pieces-double-$$.png";
-    system("inkscape -w $width_png -h $height_png -e $file_png_overlay_double $file_svg_overlay_double");
+    inkscape_export("", $width_png, $height_png, $file_png_overlay_double, $file_svg_overlay_double);
 
     $file_png_partial = "/tmp/chroma-pieces-partial-$$.png";
     system("convert -compose overlay -composite $file_png_base $file_png_overlay $file_png_partial");
index 95538bef5e460750fef3590f8cabcb1602f2ded2..280a9822063ee6662ba7b4fe98f6581648ef0b6d 100755 (executable)
@@ -21,6 +21,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+require './inkscape_export.pm';
 
 if($#ARGV != 1)
 {
@@ -85,7 +86,7 @@ sub make_pieces
     $background = "-b \"#000000\"" if($partial);
 
     # Use Inkscape to convert the SVG to a PNG
-    system("inkscape $background -w $width_png -h $height_png -e $file_png $file_svg");
+    inkscape_export($background, $width_png, $height_png, $file_png, $file_svg);
 
     for($piece = 0; $piece < $rows * $columns; $piece ++)
     {
index 1d39ca6f5a44d03e5d00f46c4bc65f84f9551281..c15e495fdf780ab93b6328ee172aa74f48cc9b79 100755 (executable)
@@ -21,6 +21,8 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+require './inkscape_export.pm';
+
 if($#ARGV != 1)
 {
     print STDERR "Usage: make-wall-marble.pl <pieces.svg> <directory>\n";
@@ -69,5 +71,5 @@ sub make_pieces
     $background = "";
 
     # Use Inkscape to convert the SVG to a PNG
-    system("inkscape $background -w $width_png -h $height_png -e $file_png $file_svg");
+    inkscape_export($background, $width_png, $height_png, $file_png, $file_svg);
 }