blob: 0a19fc3604dad2b09d36f04e757f60a768540adc [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#
Jesus Partida (PartimusPrime)f71a9222015-12-17 23:54:15 +010017# original is 1080x608
18#
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020019# cleanup screen
20clear;
21
22# resolutions
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020023RESOLUTIONS="\
Andreas Blaesius97af55b2017-08-19 12:59:49 +020024 320x181 \
Jesus Partida (PartimusPrime)f71a9222015-12-17 23:54:15 +010025 640x362 \
26 720x407 \
27 1440x814 \
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020028 ";
29
30# resize image and set quality
31convert_image() {
Jesus Partida (PartimusPrime)f71a9222015-12-17 23:54:15 +010032 convert "${1}" -resize "${2}" -quality ${3} tmp.png;
33 mv tmp.png "${1}";
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020034}
35
36# rewrite desc.txt
37rewrite_desc() {
38res=$(echo "${1}" | sed s/x/\ /)
39cat > desc.txt << EOF
Jesus Partida (PartimusPrime)f71a9222015-12-17 23:54:15 +010040${res} 60
41c 0 0 Part0
42c 1 60 Part1
43c 1 0 Part2
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020044EOF
45}
46
Humberto Borbaed550692015-03-27 11:06:36 -030047# image quality
Jesus Partida (PartimusPrime)f71a9222015-12-17 23:54:15 +010048quality=95;
Humberto Borbaed550692015-03-27 11:06:36 -030049
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020050# reading images
51for i in ${RESOLUTIONS}; do
52
53# cleanup environment
54 rm -rf "${i}";
55 rm -rf "${i}.zip";
56
57# create a temporary folder
58 mkdir -p "${i}";
59 cd ${i};
60
61 echo "============================================================";
62 echo "Resolution: ${i}"
63 echo "============================================================";
64 echo "Uncompressing bootanimation...";
65 unzip ../../bootanimation.zip > /dev/zero;
66
67 echo "Rewriting desc.txt...";
68 rewrite_desc "${i}"
69
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020070 echo "Resizing images...";
Jesus Partida (PartimusPrime)f71a9222015-12-17 23:54:15 +010071 for j in Part*/*.png; do
Humberto Borbaa5dfd9f2015-01-31 16:50:25 -020072 convert_image "${j}" "${i}" $quality;
73 echo -ne " ==> please wait...\r";
74 done
75
76 echo "";
77 echo "Compressing bootanimation...";
78 echo "";
79 zip -r0 ../${i}.zip . > /dev/zero;
80
81 sleep 1;
82 echo "Done";
83
84# remove temporary folder
85 cd ..
86 rm -rf ${i}
87done