add main.sh & fix packages
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Vri 2024-12-03 22:33:42 +01:00
parent 929edd0f36
commit 2733bb038f
Signed by: vrifox
SSH key fingerprint: SHA256:7OLOvW+jmULkXpdl5rUWgid7WJQhOIEgj+4WP/PtCpI
2 changed files with 50 additions and 1 deletions

View file

@ -1,5 +1,7 @@
FROM docker.io/alpine:latest FROM docker.io/alpine:latest
RUN apk add --no-cache imagemagick font-fira-mono-nerd pango imagemagick-pango RUN apk add --no-cache imagemagick imagemagick-jpeg imagemagick-pango font-fira-code-nerd
RUN magick --version RUN magick --version
RUN fc-cache -fv RUN fc-cache -fv
RUN fc-list RUN fc-list
COPY ./main.sh /app
ENTRYPOINT [ "/app/main.sh" ]

47
main.sh Normal file
View file

@ -0,0 +1,47 @@
#!/usr/bin/env sh
set -e
export LC_ALL='C.UTF8'
help_text() {
printf "
-t path to pango formated text file
how to format: https://usage.imagemagick.org/text/#pango
or 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 file to. Format is determined by file ending.
or as an environment variable PICTURE_PATH
if -p is set the environment variable will be ignored
"
exit 1
}
# directory of the script itself
SCRIPT_DIR="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)"
export SCRIPT_DIR
# set defaults
P_PATH="$SCRIPT_DIR/example.jpg"
I_TEXT="$(cat "$SCRIPT_DIR"/text.pango.example 2>/dev/null || echo 'example text')"
# read from environment variables
P_PATH="${PICTURE_PATH:-$P_PATH}"
I_TEXT="${IMAGE_TEXT:-$I_TEXT}"
# options, they override environment variables
while getopts "p:t:" opt
do
case "$opt" in
p) P_PATH="$OPTARG";;
t) I_TEXT=$(cat "$OPTARG");;
*) help_text
esac
done
magick \
-background '#FFFFFF' \
-fill '#000000' \
-font 'FiraCode Nerd Font' \
-pointsize 72 pango:"$I_TEXT" \
"$P_PATH"