Compare commits
3 commits
5ba3a5294c
...
0b3132e355
Author | SHA1 | Date | |
---|---|---|---|
0b3132e355 | |||
34e11c5343 | |||
b3733f3937 |
1 changed files with 24 additions and 16 deletions
34
main.sh
34
main.sh
|
@ -1,17 +1,23 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
# takes two optional arguments
|
set -ex
|
||||||
# -t path to pango formated text file
|
|
||||||
# https://usage.imagemagick.org/text/#pango
|
|
||||||
# this can be overwritten with the text inside a env var named
|
|
||||||
# IMAGE_TEXT
|
|
||||||
#
|
|
||||||
# -p is a path to write the jpg to
|
|
||||||
# alternativly you can write the path into PICTURE_PATH
|
|
||||||
set -E -o pipefail
|
|
||||||
set -x
|
|
||||||
export LC_ALL='C.UTF8'
|
|
||||||
|
|
||||||
export SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
help_text() {
|
||||||
|
printf "
|
||||||
|
-t path to pango formated text file
|
||||||
|
how to format: https://usage.imagemagick.org/text/#pango
|
||||||
|
as an environment variable IMAGE_TEXT not with path but the text itself
|
||||||
|
if -t is set the environment variable will be ignored
|
||||||
|
|
||||||
|
-p is a path to write the jpg to
|
||||||
|
as an environment variable PICTURE_PATH
|
||||||
|
if -p is set the environment variable will be ignored
|
||||||
|
"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
export LC_ALL='C.UTF8'
|
||||||
|
SCRIPT_DIR="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)"
|
||||||
|
export SCRIPT_DIR
|
||||||
|
|
||||||
P_PATH="$SCRIPT_DIR/label.jpg"
|
P_PATH="$SCRIPT_DIR/label.jpg"
|
||||||
I_TEXT="$(cat "$SCRIPT_DIR"/text.pango 2>/dev/null || echo 'example text')"
|
I_TEXT="$(cat "$SCRIPT_DIR"/text.pango 2>/dev/null || echo 'example text')"
|
||||||
|
@ -23,7 +29,8 @@ while getopts "p:t:" opt
|
||||||
do
|
do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
p) P_PATH="$OPTARG";;
|
p) P_PATH="$OPTARG";;
|
||||||
t) I_TEXT="$OPTARG";;
|
t) I_TEXT=$(cat "$OPTARG");;
|
||||||
|
*) help_text
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -33,3 +40,4 @@ magick \
|
||||||
-font 'FiraCode Nerd Font' \
|
-font 'FiraCode Nerd Font' \
|
||||||
-pointsize 72 pango:"$I_TEXT" \
|
-pointsize 72 pango:"$I_TEXT" \
|
||||||
"$P_PATH"
|
"$P_PATH"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue