blob: db0b626cf166d9cea8fffb9fa42de6a9b4df8d13 [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
Humberto Borbaed550692015-03-27 11:06:36 -030051# image quality
52quality=50;
53
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020054# reading images
55for i in ${RESOLUTIONS}; do
56
57# cleanup environment
58 rm -rf "${i}";
59 rm -rf "${i}.zip";
60
61# create a temporary folder
62 mkdir -p "${i}";
63 cd ${i};
64
65 echo "============================================================";
66 echo "Resolution: ${i}"
67 echo "============================================================";
68 echo "Uncompressing bootanimation...";
69 unzip ../../bootanimation.zip > /dev/zero;
70
71 echo "Rewriting desc.txt...";
72 rewrite_desc "${i}"
73
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020074 echo "Resizing images...";
75 for j in Part*/*.jpg; do
76 convert_image "${j}" "${i}" $quality;
77 echo -ne " ==> please wait...\r";
78 done
79
80 echo "";
81 echo "Compressing bootanimation...";
82 echo "";
83 zip -r0 ../${i}.zip . > /dev/zero;
84
85 sleep 1;
86 echo "Done";
87
88# remove temporary folder
89 cd ..
90 rm -rf ${i}
91done