-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcordova-generate-splash-screens
executable file
·63 lines (51 loc) · 2.69 KB
/
cordova-generate-splash-screens
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
#!/bin/bash
# Generate Cordova splash screens
function usage() {
echo "usage: $0 <image-filename> <background-color> [output-directory]";
exit 1;
}
[ "$1" ] && [ "$2" ] || usage
[ "$3" ] || set "$1" "$2" "."
image=$1
bgcolor=$2
output=$3/resources/splash
devices=ios,android #,windows-phone,bada,bada-wac,blackberry,webos
eval mkdir -p "$output/{$devices}"
# Show the user some progress by outputing all commands being run.
set -x
convert="convert $1 -background $bgcolor -gravity center"
function androidConvertSplash() {
drawables=drawable-land-ldpi,drawable-land-mdpi,drawable-land-hdpi,drawable-land-xhdpi,drawable-port-ldpi,drawable-port-mdpi,drawable-port-hdpi,drawable-port-xhdpi
eval mkdir -p "$output/android/{$drawables}"
$convert -resize 512x512 -extent 720x1280 "$output/android/drawable-port-xhdpi/screen.png"
$convert -resize 256x256 -extent 480x800 "$output/android/drawable-port-hdpi/screen.png"
$convert -resize 256x256 -extent 320x480 "$output/android/drawable-port-mdpi/screen.png"
$convert -resize 128x128 -extent 200x320 "$output/android/drawable-port-ldpi/screen.png"
$convert -resize 512x512 -extent 1280x720 "$output/android/drawable-land-xhdpi/screen.png"
$convert -resize 256x256 -extent 800x480 "$output/android/drawable-land-hdpi/screen.png"
$convert -resize 256x256 -extent 480x320 "$output/android/drawable-land-mdpi/screen.png"
$convert -resize 128x128 -extent 320x200 "$output/android/drawable-land-ldpi/screen.png"
function androidCopySplash() {
androidOutput=$(find . -type d | grep "platforms/android/res$")
find . -type d | grep "resources/splash/android/drawable" | xargs -I{} cp -R {} $androidOutput
}
androidCopySplash
}
androidConvertSplash
function iosConvertSplash() {
$convert -resize 1024x1024 -extent 750x1334 "$output/ios/Default-667h.png"
$convert -resize 1024x1024 -extent 1242x2208 "$output/ios/Default-736h.png"
$convert -resize 1024x1024 -extent 2208x1242 "$output/ios/Default-Landscape-736h.png"
$convert -resize 512x512 -extent 640x1136 "$output/ios/Default-568h@2x~iphone.png"
$convert -resize 1024x1024 -extent 2048x1496 "$output/ios/Default-Landscape@2x~ipad.png"
$convert -resize 512x512 -extent 1024x748 "$output/ios/Default-Landscape~ipad.png"
$convert -resize 1024x1024 -extent 1536x2008 "$output/ios/Default-Portrait@2x~ipad.png"
$convert -resize 512x512 -extent 768x1004 "$output/ios/Default-Portrait~ipad.png"
$convert -resize 256x256 -extent 320x480 "$output/ios/Default~iphone.png"
$convert -resize 256x256 -extent 640x960 "$output/ios/Default@2x~iphone.png"
function iosCopySplash() {
cp $(find . | grep "resources/splash/ios/.*\.png") "$(find . -type d | grep 'platforms/ios/.*/Resources/splash')"
}
iosCopySplash
}
iosConvertSplash