summaryrefslogtreecommitdiff
path: root/utils/nwztools/plattools/data/make_images.sh
blob: 7ac21dc17aaafa6eaf8d7e66ba2573d5f6f1909e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#
# This script contains the code used to produce all the images.
# Because of the variety of tools needed to achieve that, the result is also
# included in the repository but this makes it easier to modify the data
# to add more content
#

# path to root of repository
ROOT_DIR=../../../../

# final resolution
NWZ_WIDTH=130
NWZ_HEIGHT=130

# path to rockbox icon
RB_ICON_PATH=$ROOT_DIR/docs/logo/rockbox-icon.svg
# path to tools icon (currently stolen from KDE Oxygen icon set)
TOOL_ICON_PATH=Oxygen480-categories-preferences-system.svg

# convert_svg width height input output
function convert_svg
{
    local width="$1"
    local height="$2"
    local input="$3"
    local output="$4"
    TMP=tmp.png
    # convert from SVG to PNG
    inkscape -z -e $TMP -w $width -h $height $input
    if [ "$?" != 0 ]; then
        echo "SVG -> PNG conversion failed"
        exit 1
    fi
    # convert from PNG to BMP, force using "version 3" because the OF don't like
    # "recent" BMP
    convert -channel RGB $TMP -define bmp:format=bmp3 ${output}_icon.bmp
    if [ "$?" != 0 ]; then
        rm -f $TMP
        echo "PNG -> BMP conversion failed"
        exit 1
    fi
    # remove temporary
    rm -f $TMP
}

# start by creating the bitmap files from rockbox-icon.svg for all resolutions
# we make a detour by svg because inkscape can only export to SVG
# NOTE: we use image magick to convert to bmp but the OF tools don't like BMPv5
# and contrary to what the documentation says, image magick tends to produce
# those by default unless asked otherwise
convert_svg $NWZ_WIDTH $NWZ_HEIGHT $RB_ICON_PATH rockbox
convert_svg $NWZ_WIDTH $NWZ_HEIGHT $TOOL_ICON_PATH tools