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

29 lines
1,012 B
Bash
Executable file

#!/bin/sh
test -n "$5" || { echo "usage: ./mastodon-post.sh <text> <title> <link> <handle> </abs/path/to/out.glb>"; exit 0; }
out="$5"
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 \
\( -size 580x -background none -pointsize 32 -interline-spacing 10 -fill \#FFF -font Montserrat-SemiBold.ttf "caption:$1" \) \
-gravity center -composite \
-pointsize 20 \
-fill \#FFFFFF -gravity NorthWest -annotate +152+130 "$4" \
-fill \#9c9cc9 -gravity NorthWest -annotate +152+160 "$2" \
-fill \#9c9cc9 -gravity NorthWest -annotate +52+460 "$3" \
-define png:compression-level=9 \
-define png:compression-filter=5 \
-define png:compression-strategy=1 \
$tmpdir/mastodon-post.png
cd $tmpdir
assimp export mastodon-post.gltf $out --embed-textures