Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rendering for graphics used externally (e.g., support chat avatar) #537

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ CMakeLists.txt.*
build*
.kdev4/
*.kdev4
support-chat-avatar.png
2 changes: 1 addition & 1 deletion logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions utils/render-graphics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2023 Melvin Keskin <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-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
Loading