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 | # |
| 17 | |
| 18 | # cleanup screen |
| 19 | clear; |
| 20 | |
| 21 | # resolutions |
| 22 | # based on stock 600x400px Omni bootanimation (30fps) |
| 23 | RESOLUTIONS="\ |
| 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 |
| 36 | convert_image() { |
| 37 | convert "${1}" -resize "${2}" -quality ${3} tmp.jpg; |
| 38 | mv tmp.jpg "${1}"; |
| 39 | } |
| 40 | |
| 41 | # rewrite desc.txt |
| 42 | rewrite_desc() { |
| 43 | res=$(echo "${1}" | sed s/x/\ /) |
| 44 | cat > desc.txt << EOF |
| 45 | ${res} 30 |
| 46 | p 1 0 Part0 |
| 47 | p 0 0 Part1 |
| 48 | EOF |
| 49 | } |
| 50 | |
Humberto Borba | ed55069 | 2015-03-27 11:06:36 -0300 | [diff] [blame^] | 51 | # image quality |
| 52 | quality=50; |
| 53 | |
Humberto Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 54 | # reading images |
| 55 | for 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 Borba | a5dfd9f | 2015-01-31 16:50:25 -0200 | [diff] [blame] | 74 | 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} |
| 91 | done |