-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall_artwork.sh
executable file
·58 lines (39 loc) · 1.14 KB
/
install_artwork.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
#!/bin/bash
# This script is for converting to the artwork/icon.xcf file to a PNG and
# resizing it to the various dimensions for res/drawable-$cat/ic_launcher.png.
readonly BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
check_deps() {
if [ ! $(which xcf2png) ]; then
echo "The program 'xcf2png' is currently not installed."
exit 1
fi
if [ ! $(which convert) ]; then
echo "The program 'convert' is currently not installed."
exit 1
fi
}
convert_to_png() {
local xcf_file=$1
local png_file=$2
rm -f $png_file
xcf2png $xcf_file -o $png_file
}
do_resize() {
local width=$1
local height=$2
local icon_png=$3
local cat=$4
local out_png="$BASE_DIR/app/res/drawable-$cat/ic_launcher.png"
convert -resize ${width}x${height} $icon_png $out_png
}
main() {
local icon_xcf="$BASE_DIR/artwork/icon.xcf"
local icon_png="/tmp/sd_icon.png"
check_deps
convert_to_png $icon_xcf $icon_png
do_resize 48 48 $icon_png "mdpi"
do_resize 72 72 $icon_png "hdpi"
do_resize 96 96 $icon_png "xhdpi"
do_resize 144 144 $icon_png "xxhdpi"
}
main