fixing renderText script
This commit is contained in:
+34
-11
@@ -1,18 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
# 1. Kontrola vstupu (soubor vs stdin)
|
||||
if [ -z "$1" ]; then
|
||||
data="@-"
|
||||
# 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
|
||||
data=`cat $1`
|
||||
text_source="$1" # Cesta k souboru
|
||||
fi
|
||||
|
||||
convert \
|
||||
-font '/home/kof/.fonts/TeutonWeiss.ttf' -background black -pointsize 58 -fill '#E18A07' label:"Crypto by Kof" \
|
||||
-font '/home/kof/.fonts/TeutonNormal.otf' -background black -pointsize 12 -fill '#404040' label:"message generated @ `hostname` on `date`" \
|
||||
-background black -fill white -font '/home/kof/.fonts/SempliceRegular.ttf' -pointsize 8 -size 300x -encoding utf8 -gravity NorthWest caption:"$data" \
|
||||
-append -flatten -set label "Crypto, fuck the robots! message by k0f" -bordercolor black -border 10 /tmp/rederedText.png
|
||||
# Jistota, že cílový adresář existuje
|
||||
mkdir -p /home/kof/crypto
|
||||
|
||||
#sha=`date`_`sha1sum /tmp/rederedText.png | sed "s#[[:space:]]*/.*/.*.*##g"`
|
||||
sha="`date +%d_%m_%y__%T` by `whoami`"
|
||||
cp /tmp/rederedText.png /home/kof/crypto/"$sha".png
|
||||
# Dočasný soubor
|
||||
tmp_img="/tmp/renderedText.png"
|
||||
|
||||
# 2. Samotný rendering (Sjednoceno na šířku 500px)
|
||||
convert \
|
||||
-size 500x \
|
||||
-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"
|
||||
|
||||
Reference in New Issue
Block a user