1026ecbd38ad36f63727e8c301e23b83fd0a298c
[src/app-framework-binder.git] / docs / resources / make_cover.sh
1 #!/bin/bash
2 DOCS_DIR=$(cd $(dirname $0)/.. && pwd)
3 BOOKFILE=$DOCS_DIR/../book.json
4
5 TITLE=$(grep  '"title":' $BOOKFILE | cut -d'"' -f 4)
6 SUBTITLE=$(grep  '"subtitle":' $BOOKFILE | cut -d'"' -f 4)
7 VERSION="Version $(grep  '"version":' $BOOKFILE | cut -d'"' -f 4)"
8 DATE=$(grep  '"published":' $BOOKFILE | cut -d'"' -f 4)
9
10 [ -z "$TITLE" ] && { echo "Error TITLE not set!" ; exit 1; }
11 [ -z "$VERSION" ] && { echo "Error VERSION not set!" ; exit 1; }
12 [ -z "$DATE" ] && { echo "Error DATE not set!" ; exit 1; }
13
14
15 cat $(dirname $0)/cover.svg | sed -e "s/{title}/$TITLE/g" \
16     -e "s/font-size:87.5px/font-size:54px/g" \
17     -e "s/{subtitle}/$SUBTITLE/g" \
18     -e "s/font-size:62.5px/font-size:40px/g" \
19     -e "s/{version}/$VERSION/g" \
20     -e "s/{date}/$DATE/g" \
21     > /tmp/cover.svg
22
23 # use  imagemagick convert tool  (cover size must be 1800x2360)
24 convert -resize "1600x2160!" -border 100 -bordercolor white -background white \
25     -flatten -quality 100 /tmp/cover.svg $DOCS_DIR/cover.jpg
26
27 convert -resize "200x262!" $DOCS_DIR/cover.jpg $DOCS_DIR/cover_small.jpg