-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert2PNG
executable file
·89 lines (78 loc) · 2.08 KB
/
convert2PNG
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
if [ "$2" = "16" ]; then
resize="-filter box -resize"
width="$2"
if [ "$1" == "43" ] || [ "$1" == "32" ] || [ "$1" == "53" ] || [ "$1" == "2" ]; then
height="11"
elif [ "$1" = "1" ]; then
height="$width"
fi
elif [ "$2" = "36" ]; then
resize="-resize"
width="$2"
if [ "$1" = "43" ]; then
height="27"
elif [ "$1" = "32" ]; then
height="24"
elif [ "$1" = "53" ]; then
height="22"
elif [ "$1" = "2" ]; then
height="18"
elif [ "$1" = "1" ]; then
height="$width"
fi
elif [ "$2" = "75" ]; then
resize="-filter triangle -resize"
width="$2"
if [ "$1" = "43" ]; then
height="56"
elif [ "$1" = "32" ]; then
height="50"
elif [ "$1" = "53" ]; then
height="45"
elif [ "$1" = "2" ]; then
height="38"
elif [ "$1" = "1" ]; then
height="$width"
fi
elif [ "$2" = "225" ]; then
resize="-filter triangle -resize"
width="$2"
if [ "$1" = "43" ]; then
height="168"
elif [ "$1" = "32" ]; then
height="150"
elif [ "$1" = "53" ]; then
height="135"
elif [ "$1" = "2" ]; then
height="112"
elif [ "$1" = "1" ]; then
height="$width"
fi
else
echo "argument 2 must be 16, 36, 75, or 225"
fi
if [ -z "$height" ]; then
echo "argument 1 must be '43', '32', '53', '2', or '1'"
elif [ -n "$width" ]; then
echo "running for $width x $height"
rm -f *.png;
#uses ImageMagick
for filename in `find . -regex ".*.svg"`; do
convert -background none $filename ${resize} ${width}x${height}! ${filename%svg}png;
#filter box
#convert -background none $filename -filter triangle -interpolative-resize ${width}x${height}! -blur 0x.3 -raise 1 thumbnail.png;
#convert thumbnail.png -fill gray50 -colorize 100% -raise 1 -normalize -blur 0x4 overlay.png;
#convert thumbnail.png overlay.png -compose hardlight -composite ${filename%svg}png;
done
#rm thumbnail.png overlay.png;
echo "PNGcrush-ing"
mkdir crush${width}
for filename in `find . -regex ".*.png"`; do
pngcrush -q -rem alla -rem text $filename crush${width}/${filename:2}
done
mv -v crush${width}/* ../../png/${width}/${PWD##*/};
rm -Rf crush${width};
rm *.png;
echo "Generated $width x $height in ${PWD##*/}"
fi