newbitmaps: Get rid of ImageMagick and use PIL for image processing.

To simplify dependency (and prepare for building inside chroot), we need to get
rid of dependency for ImageMagick, which is now entirely replaceable by Python
Image Library.

BRANCH=none
BUG=none
TEST=make # pass

Change-Id: Ie3d3a4ac399b2fe58aa75f8e02e4475bcba21c51
Reviewed-on: https://gerrit.chromium.org/gerrit/37985
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
Hung-Te Lin
2012-11-14 15:10:17 +08:00
committed by Gerrit
parent 0c69afc5b3
commit 8e32e75f4f
6 changed files with 41 additions and 24 deletions

View File

@@ -23,7 +23,7 @@ default: outside_chroot strings images
outside_chroot:
@if [ -e /etc/debian_chroot ]; then \
echo "ImageMagick is too complex to build inside the chroot."; \
echo "PIL color quantization is broken inside the chroot."; \
echo "You must be outside the chroot to do this"; \
echo "(and you probably shouldn't be doing it anyway)."; \
exit 1; \

View File

@@ -85,22 +85,35 @@ bitmap block structure incompatible with previous versions.
Instructions for manually rebuilding things:
We do most of the image manipulation using ImageMagick, which is much easier
and simpler to do OUTSIDE of the chroot. So the first step is to just build
vboot_reference outside of the chroot.
Some libraries and programs (ex, PIL, pango-view) used in generating image files
need fonts set properly or specific version (ex, PIL is broken inside chroot),
and simpler to do OUTSIDE of the chroot.
On Ubuntu, you need to install following packages:
sudo apt-get install libpango1.0-dev python-imaging
And you probably want to make sure all required fonts are installed:
sudo apt-get install fonts-nanum fonts-ipafont-gothic ttf-indic-fonts \
fonts-droid
If you want to use the "bitmap viewer" utility, add these packages:
sudo apt-get install python-yaml python-wxgtk2.8
We also need some utilities from ChromiumOS source tree. You need to install
dependency libraries for them:
sudo apt-get install libtspi-dev uuid-dev libyaml-dev liblzml-dev
Now, time to build the utilities in vboot_reference outside of the chroot:
cd src/platform/vboot_reference
make
You'll probably need to install several additional packages to make this
work. On Ubuntu you may find you need libtspi-dev, uuid-dev, and
imagemagick. If you want to use scripts/newbitmaps/bitmap_viewer, you may
need python-yaml and python-wxgtk2.8.
Once you've built vboot_reference you'll find the executables in
./build/utility/ (and ./build/cgpt/cgpt, if you want it). Put these
somewhere in your $PATH.
./build/utility/bmpblk*. Put these somewhere in your $PATH.
Now you should be able to just run "make" and everything will be
regenerated:
@@ -108,8 +121,15 @@ regenerated:
cd scripts/newbitmaps
make
This should generate BIOS bmpblock file for all platforms.
This should generate BIOS bmpblock file for all platforms cross all locales,
which takes a long time.
If you simply want to build a en-US x standard resolution, do:
cd scripts/newbitmaps
make strings # You can do this only one time unless mofidication was made.
cd images
make # Builds only "STD" profile and only few seconds.
You can use the gbb_utility to modify your BIOS to contain this new set of
bitmaps:

View File

@@ -74,8 +74,10 @@ set_centered_y_percent() {
define_image() {
local image_name="$1"
local file_name="$2"
local w="$(identify -format "%[fx:w]" "$file_name")"
local h="$(identify -format "%[fx:h]" "$file_name")"
local script="import Image;s = Image.open('$file_name').size;print s[0],s[1]"
local image_size="$(python -c "$script")"
local w="${image_size%% *}"
local h="${image_size##* }"
eval "export cache_w_$image_name=$w"
eval "export cache_h_$image_name=$h"
eval "export $image_name=$file_name"

View File

@@ -34,13 +34,8 @@ main() {
done
echo "Converting glyph images..."
"$SCRIPT_DIR/text_to_png" --margin=0 --font="$FONT" --color="$COLOR" \
"$output/*.txt"
echo "Adding vertical margin to images..."
for i in $output/*.png; do
convert $i -bordercolor white -border 0x$MARGIN $i
done
"$SCRIPT_DIR/text_to_png" --font="$FONT" --color="$COLOR" \
--margin="$MARGIN 0" "$output/*.txt"
}
set -e

View File

@@ -17,7 +17,7 @@ die() {
get_width() {
local input="$1"
identify -format "%w" "$input"
python -c "import Image; print Image.open('$input').size[0]"
}
do_locale() {

View File

@@ -98,7 +98,7 @@ for txtfile in $*; do
--hinting=full \
--background="$bgcolor" --foreground="$color" \
--font="$font $pointsize" --dpi 72 \
--margin=$margin \
--margin="$margin" \
--align="$align" \
$params $file_opt \
--output "$pngfile" \