#!/usr/bin/env sh set -ex 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' export SCRIPT_DIR="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)" P_PATH="$SCRIPT_DIR/label.jpg" I_TEXT="$(cat "$SCRIPT_DIR"/text.pango 2>/dev/null || echo 'example text')" P_PATH="${PICTURE_PATH:-$P_PATH}" I_TEXT="${IMAGE_TEXT:-$I_TEXT}" 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"