Compare commits
No commits in common. "0b3132e355e8b3732e3d6ba98177534cd03d4b9f" and "5ba3a5294c1fed7a531d3579ccab1e1ab6799ef5" have entirely different histories.
0b3132e355
...
5ba3a5294c
1 changed files with 16 additions and 24 deletions
40
main.sh
40
main.sh
|
@ -1,23 +1,17 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
set -ex
|
# takes two optional arguments
|
||||||
|
# -t path to pango formated text file
|
||||||
help_text() {
|
# https://usage.imagemagick.org/text/#pango
|
||||||
printf "
|
# this can be overwritten with the text inside a env var named
|
||||||
-t path to pango formated text file
|
# IMAGE_TEXT
|
||||||
how to format: https://usage.imagemagick.org/text/#pango
|
#
|
||||||
as an environment variable IMAGE_TEXT not with path but the text itself
|
# -p is a path to write the jpg to
|
||||||
if -t is set the environment variable will be ignored
|
# alternativly you can write the path into PICTURE_PATH
|
||||||
|
set -E -o pipefail
|
||||||
-p is a path to write the jpg to
|
set -x
|
||||||
as an environment variable PICTURE_PATH
|
|
||||||
if -p is set the environment variable will be ignored
|
|
||||||
"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
export LC_ALL='C.UTF8'
|
export LC_ALL='C.UTF8'
|
||||||
SCRIPT_DIR="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)"
|
|
||||||
export SCRIPT_DIR
|
export SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
||||||
|
|
||||||
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')"
|
||||||
|
@ -27,11 +21,10 @@ I_TEXT="${IMAGE_TEXT:-$I_TEXT}"
|
||||||
|
|
||||||
while getopts "p:t:" opt
|
while getopts "p:t:" opt
|
||||||
do
|
do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
p) P_PATH="$OPTARG";;
|
p) P_PATH="$OPTARG";;
|
||||||
t) I_TEXT=$(cat "$OPTARG");;
|
t) I_TEXT="$OPTARG";;
|
||||||
*) help_text
|
esac
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
magick \
|
magick \
|
||||||
|
@ -40,4 +33,3 @@ 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