-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert-icons.pl
executable file
·68 lines (55 loc) · 1.26 KB
/
convert-icons.pl
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/perl
use strict;
use warnings;
my @heights = (18, 20, 24, 36, 38, 40, 48, 50, 64);
sub run(@){
print "@_\n";
system @_;
}
sub convertRsvg($$$){
my ($src, $dest, $h) = @_;
if(`which rsvg-convert` =~ /rsvg-convert/){
run "rsvg-convert",
"-h", $h,
"-a",
"-f", "png",
"-o", $dest,
$src;
}elsif(`which rsvg` =~ /rsvg/){
run "rsvg",
"-h", $h,
"-a",
"-f", "png",
"-o", $dest,
$src, "$dest";
}
}
sub convertImageMagick($$$){
my ($src, $dest, $h) = @_;
run "convert", "-resize", "${h}", $src, $dest;
}
sub convert($$$){
my $baseName = shift;
my $baseDir = shift;
}
sub main(@){
chdir 'icons';
my @imgs = `cd svg; find -name '*.svg'`;
run "rm", "-r", "xpm";
run "rm", "-r", "png";
for my $h(@heights){
for my $img(@imgs){
chomp $img;
my $baseName = $img;
$baseName =~ s/\.([a-zA-Z0-9]+)$//;
my $baseDir = $baseName;
$baseDir =~ s/\/[^\/]*$//;
my $size = "${h}x${h}";
run "mkdir", "-p", "png/$size/$baseDir";
convertRsvg "svg/$baseName.svg", "png/$size/$baseName.png", $h;
run "mkdir", "-p", "xpm/$size/$baseDir";
convertImageMagick "svg/$baseName.svg", "xpm/$size/$baseName.xpm", $h;
}
}
}
&main(@ARGV);