Files
bin/renderText
T

42 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# 1. Kontrola vstupu (soubor vs stdin)
if [ -z "$1" ]; then
# Pokud stdin není roura ani přesměrovaný soubor, vyhodíme chybu a nevisíme
if [ -t 0 ]; then
echo "Chyba: Skript čeká data z roury (pipe) nebo cestu k souboru!" >&2
echo "Použití: echo \"moje zpráva\" | $0" >&2
echo "Nebo: $0 soubor.txt" >&2
exit 1
fi
text_source="-" # ImageMagick si to přebere jako stdin
else
text_source="$1" # Cesta k souboru
fi
# Jistota, že cílový adresář existuje
mkdir -p /home/kof/crypto
# Dočasný soubor
tmp_img="/tmp/renderedText.png"
# 2. Samotný rendering (Sjednoceno na šířku 500px)
convert \
-size 512x \
-background black \
-fill '#E18A07' -font '/home/kof/.fonts/TeutonWeiss.ttf' -pointsize 58 -gravity center caption:"Crypto by Kof" \
-fill '#404040' -font '/home/kof/.fonts/TeutonNormal.otf' -pointsize 12 -gravity center caption:"message generated @ $(hostname) on $(date)" \
-fill white -font '/home/kof/.fonts/SempliceRegular.ttf' -pointsize 8 -gravity NorthWest caption:"@$text_source" \
-append \
-set label "Crypto, fuck the robots! message by k0f" \
-bordercolor black -border 10 \
"$tmp_img"
# 3. Bezpečný timestamp bez dvojteček (formát: DD_MM_YY__HH-MM-SS)
sha="$(date +%d_%m_%y__%H-%M-%S)_by_$(whoami)"
# Přesun do archivu
cp "$tmp_img" /home/kof/crypto/"$sha".png
echo "Renderováno do: /home/kof/crypto/${sha}.png"