blob: 8448105057356290f39dbf938943a048a4b0be6a [file] [log] [blame]
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -02001#!/bin/sh
2#
3# Copyright (C) 2015 OmniROM Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18# cleanup screen
19clear;
20
21# resolutions
22# based on stock 600x400px Omni bootanimation (30fps)
23RESOLUTIONS="\
24 360x240 \
25 420x280 \
26 480x320 \
27 720x480 \
28 840x560 \
29 960x640 \
30 1080x720 \
31 1440x960 \
32 2560x1440 \
33 ";
34
35# resize image and set quality
36convert_image() {
37 convert "${1}" -resize "${2}" -quality ${3} tmp.jpg;
38 mv tmp.jpg "${1}";
39}
40
41# rewrite desc.txt
42rewrite_desc() {
43res=$(echo "${1}" | sed s/x/\ /)
44cat > desc.txt << EOF
45${res} 30
46p 1 0 Part0
47p 0 0 Part1
48EOF
49}
50
51# reading images
52for i in ${RESOLUTIONS}; do
53
54# cleanup environment
55 rm -rf "${i}";
56 rm -rf "${i}.zip";
57
58# create a temporary folder
59 mkdir -p "${i}";
60 cd ${i};
61
62 echo "============================================================";
63 echo "Resolution: ${i}"
64 echo "============================================================";
65 echo "Uncompressing bootanimation...";
66 unzip ../../bootanimation.zip > /dev/zero;
67
68 echo "Rewriting desc.txt...";
69 rewrite_desc "${i}"
70
71# set image quality
72# add an aggressive value for low resolutions
73 case "${i}" in
74 "360x240"|"420x280"|"480x320")
75 quality=80;
76 ;;
77 *)
78 quality=90;
79 ;;
80 esac
81
82 echo "Resizing images...";
83 for j in Part*/*.jpg; do
84 convert_image "${j}" "${i}" $quality;
85 echo -ne " ==> please wait...\r";
86 done
87
88 echo "";
89 echo "Compressing bootanimation...";
90 echo "";
91 zip -r0 ../${i}.zip . > /dev/zero;
92
93 sleep 1;
94 echo "Done";
95
96# remove temporary folder
97 cd ..
98 rm -rf ${i}
99done