From 19b0960fe4cc58d38fdda95d6f4638070dc2ac3a Mon Sep 17 00:00:00 2001 From: ranomier Date: Tue, 3 Dec 2024 01:32:15 +0100 Subject: [PATCH] initial commit --- .gitignore | 2 ++ Dockerfile | 2 ++ main.sh | 34 ++++++++++++++++++++++++++++++++++ text.pango.example | 1 + 4 files changed, 39 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100755 main.sh create mode 100644 text.pango.example diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f4f5711 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +text.pango +label.jpg diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f67b9d2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM docker.io/alpine:latest +RUN apk add imagemagick imagemagick-jpeg imagemagick-pango font-fira-code-nerd diff --git a/main.sh b/main.sh new file mode 100755 index 0000000..d5b67ae --- /dev/null +++ b/main.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env sh +# takes two optional arguments +# -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 +#shopt -s failglob +export LC_ALL='C.UTF8' + +P_PATH="./label.jpg" +I_TEXT="$(cat ./text.pango)" + +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="$OPTARG";; + esac +done + +magick \ + -background '#FFFFFF' \ + -fill '#000000' \ + -font 'FiraCode Nerd Font' \ + -pointsize 72 pango:"$I_TEXT" \ + "$P_PATH" diff --git a/text.pango.example b/text.pango.example new file mode 100644 index 0000000..21d0393 --- /dev/null +++ b/text.pango.example @@ -0,0 +1 @@ +Pretty example text with Pango