-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy path2svg
executable file
·41 lines (32 loc) · 1.17 KB
/
2svg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl
#
# convert images (including DXF files) to SVG, useful for converting Fusion 360 sketches to SVG
# requires Inkscape
#
# -samy kamkar
# Possible paths to Inkscape binary
my @inkscape = (qw|
/Applications/Design/Inkscape.app/Contents/Resources/bin/inkscape
/Applications/Design/Inkscape.app/Contents/Resources/bin/inkscape-bin
/Applications/Design/Inkscape.app/Contents/MacOS/Inkscape
/opt/local/bin/inkscape
/Applications/Inkscape.app/Contents/Resources/bin/inkscape
/Applications/Inkscape.app/Contents/Resources/bin/inkscape-bin
/Applications/Inkscape.app/Contents/MacOS/Inkscape
|, map { "$_/inkscape" } split(/:/, $ENV{PATH}));
# options to pass to inkscape
my @opts = qw/-z -l/;
# Find path to inkscape
my ($INKSCAPE) = grep -e, @inkscape;
die "You must have inkscape installed or discoverable from your \$PATH" unless $INKSCAPE;
use Cwd;
use strict;
die "usage: $0 <from file> [to svg file]\n" unless @ARGV;
my $cwd = cwd();
my ($from, $to) = @ARGV;
# need absolute paths
$from = "$cwd/$from" unless $from =~ m|^/|;
# out filename
($to = $from) =~ s/\.\w+$/.svg/ unless defined($to);
print "Converting $from -> $to!\n";
system($INKSCAPE, @opts, $to, $from);