File: render-graphics.sh

package info (click to toggle)
qxmpp 1.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,480 kB
  • sloc: cpp: 73,257; xml: 1,345; ansic: 362; sh: 176; makefile: 16
file content (39 lines) | stat: -rwxr-xr-x 960 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

# SPDX-FileCopyrightText: 2023 Melvin Keskin <melvo@olomono.de>
#
# SPDX-License-Identifier: LGPL-2.1-or-later

QXMPP_SOURCES=$(dirname "$(readlink -f "${0}")")/..

echo "*****************************************"
echo "Rendering graphics"
echo "*****************************************"

render_support_chat_avatar() {
    render_svg_with_margin $QXMPP_SOURCES/logo.svg $QXMPP_SOURCES/support-chat-avatar.png 300 300 18
}

# $1 - $4: see render_svg()
# $5: margin
render_svg_with_margin() {
    output_directory=$(dirname $2)
    mkdir -p $output_directory
    tmp_file=$output_directory/rendered_tmp.svg
    inkscape -o $tmp_file --export-margin=$5 $1
    render_svg $tmp_file $2 $3 $4
    rm $tmp_file
}

# $1: input file
# $2: output file
# $3: width
# $4: height
render_svg() {
    inkscape -o $2 -w $3 -h $4 $1 >/dev/null
    optipng -quiet -o7 $2 >/dev/null
    advpng -z4 $2 >/dev/null
    echo "Created "$2
}

render_support_chat_avatar