This repository has been archived by the owner on May 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
makeicons
executable file
·62 lines (50 loc) · 1.83 KB
/
makeicons
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
#!/bin/bash
#
# Helper script to generate icons and logos
#
# Usage: inkscape_export inputFile outputFile size
inkscape_export () {
# TODO: Check parameters
echo " - $2 (${3}px)"
outputDir=$(dirname $2)
if [ ! -d ${outputDir} ]; then
mkdir -p ${outputDir}
fi
inkscape --export-png $2 -w $3 $1 &> /dev/null
}
CURRENTDIR=$PWD
SCRIPT="${BASH_SOURCE[0]}"
while [ -h "$SCRIPT" ]; do
SCRIPTPATH="$( cd -P "$( dirname "$SCRIPT" )" && pwd )"
SCRIPT="$(readlink "$SCRIPT")"
[[ $SCRIPT != /* ]] && SOURCE="$SCRIPTPATH/$SCRIPT"
done
SCRIPTPATH="$( cd -P "$( dirname "$SCRIPT" )" && pwd )"
cd "$PWD"
# TODO: Object array?
declare -a sourceFiles=("icon.svg" "icon-debug.svg" "icon.svg" "icon-debug.svg" "brand.svg")
declare -a targetFiles=("ic_launcher.png" "ic_launcher2.png" "splash_logo.png" "splash_logo2.png" "splash_brand.png")
declare -a targetDirs=("mipmap" "mipmap" "drawable" "drawable" "drawable")
# All densities we are interested in
declare -a densities=("xxxhdpi" "xxhdpi" "xhdpi" "hdpi" "mdpi")
declare -a targetFileSizes=("192 144 96 72 48" "192 144 96 72 48" "640 480 320 240 160" "640 480 320 240 160" "896 672 448 336 224")
targetFilesCount=${#targetFiles[@]}
echo ""
echo "[#] Exporting high quality icon for Play Store..."
inkscape_export ${CURRENTDIR}/artwork/icon.svg ${CURRENTDIR}/icon.png 512
echo "[#] Generating resources..."
for (( i = 0; i < ${targetFilesCount}; i++ )); do
sourceFile="${sourceFiles[$i]}"
targetFile="${targetFiles[$i]}"
targetDir="${targetDirs[$i]}"
sizeArray=(${targetFileSizes[$i]})
for (( j = 0; j < ${#sizeArray[@]}; j++ )); do
density=${densities[$j]}
size=${sizeArray[j]}
fileName=${CURRENTDIR}/app/src/main/res/${targetDir}-${density}/${targetFile}
inkscape_export ${CURRENTDIR}/artwork/${sourceFile} ${fileName} ${size}
done
done
echo "[i] Finished"
echo ""
exit 0