forked from bobafetthotmail/refind-theme-regular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_bitmap.sh
executable file
·81 lines (73 loc) · 2.18 KB
/
render_bitmap.sh
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
#!/bin/bash
#
INKSCAPE=`which inkscape 2> /dev/null`
OPTIPNG=`which optipng 2> /dev/null`
OUT="bitmap"
BIG_ICON_SRC_DIR="svg/big"
SMALL_ICON_SRC_DIR="svg/small"
REG_BIG_ICON_FILENAME='s/^svg\/big\///g;s/.svg$//g'
REG_SMALL_ICON_FILENAME='s/^svg\/small\///g;s/.svg$//g'
DPI=96
SCALE_PRESET=(1 2 3 4)
SCALE=1
SRC_DIR=""
OUT_DIR=""
REG=''
function render_bitmap(){
for svgfile in $(ls $SRC_DIR | grep .svg)
do
filename=$(echo $svgfile | sed $REG)
if [ -f "$OUT_DIR/$filename.png" ]
then
echo "'$OUT_DIR/$filename.png' already exists"
else
echo "Creating... $OUT_DIR/$filename.png"
$INKSCAPE --export-area-page \
--export-dpi=$(($SCALE*$DPI)) \
--export-png="$OUT_DIR/$filename.png" $SRC_DIR/$svgfile> /dev/null \
&&
if [[ -x $OPTIPNG ]]
then
$OPTIPNG -o7 --quiet "$OUT_DIR/$filename.png"
fi
fi
done
if [ -f $OUT_DIR/os_unknown.png ]
then
for f in os_clover os_gummiboot os_hwtest os_refit os_network os_systemd-boot
do
echo "Copying... $OUT_DIR/$f.png"
cp -f "$OUT_DIR/os_unknown.png" "$OUT_DIR/$f.png"
done
fi
if [ -f $OUT_DIR/tool_rescue.png ]
then
for f in tool_apple_rescue tool_windows_rescue
do
echo "Copying... $OUT_DIR/$f.png"
cp -f "$OUT_DIR/tool_rescue.png" "$OUT_DIR/$f.png"
done
fi
}
function render_big_icon(){
SCALE=$i
REG=$REG_BIG_ICON_FILENAME
SRC_DIR=$BIG_ICON_SRC_DIR
OUT_DIR="$OUT/big_$(($i*128))"
mkdir -p $OUT_DIR
render_bitmap
}
function render_small_icon(){
SCALE=$i
REG=$REG_SMALL_ICON_FILENAME
SRC_DIR=$SMALL_ICON_SRC_DIR
OUT_DIR="$OUT/small_$(($i*48))"
mkdir -p $OUT_DIR
render_bitmap
}
for i in ${SCALE_PRESET[@]}
do
render_big_icon
render_small_icon
done
exit 0