Humberto Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 1 | #!/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) | f71a922 | 2015-12-17 23:54:15 +0100 | [diff] [blame] | 17 | # original is 1080x608 |
| 18 | # |
Humberto Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 19 | # cleanup screen |
| 20 | clear; |
| 21 | |
| 22 | # resolutions |
Humberto Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 23 | RESOLUTIONS="\ |
Andreas Blaesius | 97af55b | 2017-08-19 12:59:49 +0200 | [diff] [blame] | 24 | 320x181 \ |
Jesus Partida (PartimusPrime) | f71a922 | 2015-12-17 23:54:15 +0100 | [diff] [blame] | 25 | 640x362 \ |
| 26 | 720x407 \ |
| 27 | 1440x814 \ |
Humberto Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 28 | "; |
| 29 | |
| 30 | # resize image and set quality |
| 31 | convert_image() { |
Jesus Partida (PartimusPrime) | f71a922 | 2015-12-17 23:54:15 +0100 | [diff] [blame] | 32 | convert "${1}" -resize "${2}" -quality ${3} tmp.png; |
| 33 | mv tmp.png "${1}"; |
Humberto Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | # rewrite desc.txt |
| 37 | rewrite_desc() { |
| 38 | res=$(echo "${1}" | sed s/x/\ /) |
| 39 | cat > desc.txt << EOF |
Jesus Partida (PartimusPrime) | f71a922 | 2015-12-17 23:54:15 +0100 | [diff] [blame] | 40 | ${res} 60 |
| 41 | c 0 0 Part0 |
| 42 | c 1 60 Part1 |
| 43 | c 1 0 Part2 |
Humberto Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 44 | EOF |
| 45 | } |
| 46 | |
Humberto Borba | ed55069 | 2015-03-27 11:06:36 -0300 | [diff] [blame] | 47 | # image quality |
Jesus Partida (PartimusPrime) | f71a922 | 2015-12-17 23:54:15 +0100 | [diff] [blame] | 48 | quality=95; |
Humberto Borba | ed55069 | 2015-03-27 11:06:36 -0300 | [diff] [blame] | 49 | |
Humberto Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 50 | # reading images |
| 51 | for 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 Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 70 | echo "Resizing images..."; |
Jesus Partida (PartimusPrime) | f71a922 | 2015-12-17 23:54:15 +0100 | [diff] [blame] | 71 | for j in Part*/*.png; do |
Humberto Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 72 | 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} |
| 87 | done |