-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpng_resize.sh
executable file
·141 lines (118 loc) · 2.96 KB
/
png_resize.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
image=$1
start_resolution=$2
start_type=0
if [ $start_resolution = "xxxhdpi" ]; then
start_type=6
fi
if [ $start_resolution = "xxhdpi" ]; then
start_type=5
fi
if [ $start_resolution = "xhdpi" ]; then
start_type=4
fi
if [ $start_resolution = "hdpi" ]; then
start_type=3
fi
if [ $start_resolution = "mdpi" ]; then
start_type=2
fi
percent_xxxhdpi=100%
percent_xxhdpi=75%
percent_xhdpi=50%
percent_hdpi=37%
percent_mdpi=25%
percent_ldpi=19%
if [ "$start_type" -eq 5 ]; then
percent_xxxhdpi=100%
percent_xxhdpi=100%
percent_xhdpi=67%
percent_hdpi=50%
percent_mdpi=33%
percent_ldpi=25%
fi
if [ "$start_type" -eq 4 ]; then
percent_xxxhdpi=100%
percent_xxhdpi=100%
percent_xhdpi=100%
percent_hdpi=75%
percent_mdpi=50%
percent_ldpi=37%
fi
if [ "$start_type" -eq 3 ]; then
percent_xxxhdpi=100%
percent_xxhdpi=100%
percent_xhdpi=100%
percent_hdpi=100%
percent_mdpi=67%
percent_ldpi=50%
fi
if [ "$start_type" -eq 2 ]; then
percent_xxxhdpi=100%
percent_xxhdpi=100%
percent_xhdpi=100%
percent_hdpi=100%
percent_mdpi=100%
percent_ldpi=75%
fi
if [ "$start_type" -eq 1 ]; then
percent_xxxhdpi=100%
percent_xxhdpi=100%
percent_xhdpi=100%
percent_hdpi=100%
percent_mdpi=100%
percent_ldpi=100%
fi
if [ -d "./drawable-xxxhdpi" ]; then
echo "Not need to create directory ./drawable-xxxhdpi because already exist"
else
echo "Creating directory ./drawable-xxxhdpi."
mkdir drawable-xxxhdpi
fi
echo "Resizing image for xxxhdpi resolution"
convert -resize $percent_xxxhdpi $image drawable-xxxhdpi/$image
echo " "
if [ -d "./drawable-xxhdpi" ]; then
echo "Not need to create directory ./drawable-xxhdpi because already exist"
else
echo "Creating directory ./drawable-xxhdpi."
mkdir drawable-xxhdpi
fi
echo "Resizing image for xxhdpi resolution"
convert -resize $percent_xxhdpi $image drawable-xxhdpi/$image
echo " "
if [ -d "./drawable-xhdpi" ]; then
echo "Not need to create directory ./drawable-xhdpi because already exist"
else
echo "Creating directory ./drawable-xhdpi."
mkdir drawable-xhdpi
fi
echo "Resizing image for xhdpi resolution"
convert -resize $percent_xhdpi $image drawable-xhdpi/$image
echo " "
if [ -d "./drawable-hdpi" ]; then
echo "Not need to create directory ./drawable-hdpi because already exist"
else
echo "Creating directory ./drawable-hdpi."
mkdir drawable-hdpi
fi
echo "Resizing image for hdpi resolution"
convert -resize $percent_hdpi $image drawable-hdpi/$image
echo " "
if [ -d "./drawable-mdpi" ]; then
echo "Not need to create directory ./drawable-mdpi because already exist"
else
echo "Creating directory ./drawable-mdpi."
mkdir drawable-mdpi
fi
echo "Resizing image for mdpi resolution"
convert -resize $percent_mdpi $image drawable-mdpi/$image
echo " "
if [ -d "./drawable-ldpi" ]; then
echo "Not need to create directory ./drawable-ldpi because already exist"
else
echo "Creating directory ./drawable-ldpi."
mkdir drawable-ldpi
fi
echo "Resizing image for ldpi resolution"
convert -resize $percent_ldpi $image drawable-ldpi/$image