xrforge/manyfold/root/templates/mastodon-post/mastodon-post.sh

31 lines
985 B
Bash
Raw Normal View History

2025-11-20 11:06:23 +01:00
#!/bin/sh
test -n "$6" || { echo "usage: ./mastodon-post.sh <text> <title> <link> <handle> <ttf-file> </abs/path/to/out.glb>"; exit 0; }
out="$6"
tmpdir=/tmp/.mastodon-post
mydir="$(dirname $(readlink -f $0))"
cd $mydir
# create tmp workspace
test -d $tmpdir && rm -rf $tmpdir
mkdir $tmpdir
cp * $tmpdir/.
rm $tmpdir/mastodon-post.png # IMPORTANT: prevent newer/older imagemagick -clobber (non)existence
set -x
magick $tmpdir/mastodon-post-bg.png \
\( -background none -pointsize 48 -interline-spacing 10 -fill \#FFF -font "$5" "caption:$1" \) \
-gravity center -composite \
-pointsize 18 \
-fill \#FFFFFF -gravity NorthWest -annotate +152+100 "$4" \
-fill \#9c9cc9 -gravity NorthWest -annotate +152+130 "$2" \
-fill \#9c9cc9 -gravity NorthWest -annotate +40+470 "$3" \
PNG8:$tmpdir/mastodon-post.png
# -define png:compression-level=9 \
# -define png:compression-filter=5 \
# -define png:compression-strategy=1 \
cd $tmpdir
assimp export mastodon-post.gltf $out