OLD | NEW |
---|---|
1 #!/bin/bash -e | 1 #!/bin/bash -e |
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 # | 5 # |
6 # This adds text to our non-labeled recovery images. | 6 # This adds text to our non-labeled recovery images. |
7 # | 7 # |
8 # The source images should be 1366x800, with the expectation they'll be cropped | 8 # The source images should be 1366x800, with the expectation they'll be cropped |
9 # to 1366x768 or 1280x800, have 2 lines of text overlayed at the bottom, and | 9 # to <screen geometry>, which is 1366x768 or 1280x800, have 2 lines of text |
10 # then be resized to 800x600 so that the BIOS can then display them stretched | 10 # overlayed at the bottom, and then be resized to 800x600 if on x86, otherwise |
11 # to the full screen size. | 11 # same as <screen geometry>. On x86, resizing to 800x600 because the BIOS can |
12 # then display them stretched to the full screen size. | |
12 # | 13 # |
13 | 14 |
14 | 15 |
15 | 16 # Require three args |
16 | 17 if [ $# -ne "3" -o \( $3 != "true" -a $3 != "false" \) ]; then |
Bill Richardson
2011/01/27 17:46:28
Let's change the last argument to either 'x86' or
Tom Wai-Hong Tam
2011/01/28 01:24:03
Done.
| |
17 # Require one arg | 18 echo "Usage: $(basename $0) <HWID> <screen geometry> <x86? true/false>" 1>&2 |
18 if [ $# -ne "2" ]; then | |
19 echo "Usage: $(basename $0) <MODEL> <screen geometry>" 1>&2 | |
20 exit 1 | 19 exit 1 |
21 fi | 20 fi |
22 MODEL=$1 | 21 HWID=$1 |
23 geom_crop=$2 | 22 geom_crop=$2 |
23 geom_final='800x600!' | |
24 flag_final= | |
25 # If not x86, make the final geometry as screen size and use 8bpp rle format. | |
26 if [ $3 = "false" ]; then | |
27 geom_final=$2 | |
28 flag_final="-colors 256 -compress rle" | |
29 fi | |
24 | 30 |
25 nicename=${MODEL// /_} | 31 nicename=${HWID// /_} |
26 | 32 |
27 # Default URL | 33 # Default URL |
28 URL='http://google.com/chromeos/recovery' | 34 URL='http://google.com/chromeos/recovery' |
29 | 35 |
30 # Image parameters | 36 # Image parameters |
31 geom_orig='1366x800' | 37 geom_orig='1366x800' |
32 geom_final='800x600!' | |
33 bluecolor='#9ccaec' | 38 bluecolor='#9ccaec' |
34 bluefont="Helvetica-Narrow" | 39 bluefont="Helvetica-Narrow" |
35 bluepointsize=30 | 40 bluepointsize=30 |
36 whitefont="Helvetica-Narrow" | 41 whitefont="Helvetica-Narrow" |
37 whitepointsize=48 | 42 whitepointsize=48 |
38 | 43 |
39 | 44 |
40 # Temporary files | 45 # Temporary files |
41 tmpdir=$(mktemp -d /tmp/tmp.bmp.XXXXXX) | 46 tmpdir=$(mktemp -d /tmp/tmp.bmp.XXXXXX) |
42 trap "rm -rf $tmpdir" EXIT | 47 trap "rm -rf $tmpdir" EXIT |
43 img_orig="${tmpdir}/img_orig.bmp" | 48 img_orig="${tmpdir}/img_orig.bmp" |
44 img_crop="${tmpdir}/img_crop.bmp" | 49 img_crop="${tmpdir}/img_crop.bmp" |
45 img_txt="${tmpdir}/img_txt.bmp" | 50 img_txt="${tmpdir}/img_txt.bmp" |
46 label_file="${tmpdir}/label.txt" | 51 label_file="${tmpdir}/label.txt" |
47 label_img="${tmpdir}/label.bmp" | 52 label_img="${tmpdir}/label.bmp" |
48 | 53 |
49 # Output directories | 54 # Output directories |
50 thisdir=$(readlink -e $(dirname $0)) | 55 thisdir=$(readlink -e $(dirname $0)) |
51 outdir="${thisdir}/out_${nicename}" | 56 outdir="out_${nicename}" |
52 [ -d "$outdir" ] || mkdir -p "$outdir" | 57 [ -d "$outdir" ] || mkdir -p "$outdir" |
53 | 58 |
54 function find_background_color { | 59 function find_background_color { |
55 src_img=$1 | 60 src_img=$1 |
56 convert "$src_img" -crop '1x1+10+10!' txt:- | \ | 61 convert "$src_img" -crop '1x1+10+10!' txt:- | \ |
57 perl -n -e 'print "$1" if m/(#[0-9a-f]+)/i;' | 62 perl -n -e 'print "$1" if m/(#[0-9a-f]+)/i;' |
58 } | 63 } |
59 | 64 |
60 function process_one_file { | 65 function process_one_file { |
61 src_img=$1 | 66 src_img=$1 |
(...skipping 15 matching lines...) Expand all Loading... | |
77 | 82 |
78 # Now crop that to the two target sizes | 83 # Now crop that to the two target sizes |
79 convert "$img_orig" -gravity Center \ | 84 convert "$img_orig" -gravity Center \ |
80 -crop "$geom_crop"+0+0 +repage "$img_crop" | 85 -crop "$geom_crop"+0+0 +repage "$img_crop" |
81 | 86 |
82 # Add the labels in | 87 # Add the labels in |
83 if [ -r "$txt_file" ]; then | 88 if [ -r "$txt_file" ]; then |
84 # The only way to change font and color in multiline text is to split each | 89 # The only way to change font and color in multiline text is to split each |
85 # line into a separate image and then composite them together. Ugh. | 90 # line into a separate image and then composite them together. Ugh. |
86 # First, split each input line into a separate file. | 91 # First, split each input line into a separate file. |
87 "${thisdir}/makelines" -u "$URL" -m "$MODEL" -d "$tmpdir" "$txt_file" | 92 "${thisdir}/makelines.sh" -u "$URL" -m "$HWID" -d "$tmpdir" "$txt_file" |
88 # Convert each line file into an image file. | 93 # Convert each line file into an image file. |
89 for txtfile in ${tmpdir}/linetxt_*; do | 94 for txtfile in ${tmpdir}/linetxt_*; do |
90 case "$txtfile" in | 95 case "$txtfile" in |
91 *.txt) | 96 *.txt) |
92 convert \ | 97 convert \ |
93 -background "$bg" -fill "$bluecolor" \ | 98 -background "$bg" -fill "$bluecolor" \ |
94 -font "$bluefont" -pointsize "$bluepointsize" \ | 99 -font "$bluefont" -pointsize "$bluepointsize" \ |
95 -bordercolor "$bg" -border 0x1 \ | 100 -bordercolor "$bg" -border 0x1 \ |
96 label:'@'"$txtfile" "${txtfile%.*}".bmp | 101 label:'@'"$txtfile" "${txtfile%.*}".bmp |
97 ;; | 102 ;; |
98 *.TXT) | 103 *.TXT) |
99 convert \ | 104 convert \ |
100 -background "$bg" -fill "white" \ | 105 -background "$bg" -fill "white" \ |
101 -font "$whitefont" -pointsize "$whitepointsize" \ | 106 -font "$whitefont" -pointsize "$whitepointsize" \ |
102 -bordercolor "$bg" -border 0x10 \ | 107 -bordercolor "$bg" -border 0x10 \ |
103 label:'@'"$txtfile" "${txtfile%.*}".bmp | 108 label:'@'"$txtfile" "${txtfile%.*}".bmp |
104 ;; | 109 ;; |
105 esac | 110 esac |
106 done | 111 done |
107 # Now bash them all together to make one image. | 112 # Now bash them all together to make one image. |
108 convert -background "$bg" -gravity center ${tmpdir}/linetxt_*.bmp \ | 113 convert -background "$bg" -gravity center ${tmpdir}/linetxt_*.bmp \ |
109 label:'\n\n\n\n' -append "$label_img" | 114 label:'\n\n\n\n' -append "$label_img" |
110 # Finally, layer the label image on top of the original. | 115 # Finally, layer the label image on top of the original. |
111 composite "$label_img" -gravity south "$img_crop" "$img_txt" | 116 composite "$label_img" -gravity south "$img_crop" "$img_txt" |
112 else | 117 else |
113 mv "$img_crop" "$img_txt" | 118 mv "$img_crop" "$img_txt" |
114 fi | 119 fi |
115 | 120 |
116 # Now scale the result to the final size | 121 # Now scale the result to the final size |
117 convert "$img_txt" -scale "$geom_final" -alpha off "$dst_img" | 122 convert "$img_txt" -scale "$geom_final" -alpha off $flag_final "$dst_img" |
118 } | 123 } |
119 | 124 |
120 | 125 |
121 # Do it. | 126 # Do it. |
122 for file in originals/*.gif; do | 127 for file in ${thisdir}/originals/*.gif; do |
123 process_one_file "$file" | 128 process_one_file "$file" |
124 done | 129 done |
125 | 130 |
126 # Zip up the bitmaps | 131 # Zip up the bitmaps |
127 (cd "$outdir" && zip -qr "${geom_crop}.zip" *) | 132 (cd "$outdir" && zip -qr "${geom_crop}.zip" *) |
OLD | NEW |