Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Cek dependencies
- for cmd in convert yad fc-list bc; do
- if ! command -v $cmd >/dev/null 2>&1; then
- echo "Error: $cmd tidak ditemukan. Instal via sudo apt install imagemagick yad"
- exit 1
- fi
- done
- # 1. Ambil input user sekaligus (Teks & Rotasi)
- user_input=$(yad --form --title="Watermark Settings" --width=350 --center \
- --field="Teks Watermark" "Sample Watermark" \
- --field="Rotasi:CB" "0!90!180!270")
- [[ $? -ne 0 ]] && exit 1
- TEXT=$(echo "$user_input" | cut -d'|' -f1)
- ROTATION=$(echo "$user_input" | cut -d'|' -f2)
- # 2. Setup Font
- FONT="Noto-Sans-Casual"
- if ! fc-list | grep -qi "$FONT"; then
- FONT="Sans"
- fi
- # 3. Proses File
- for FILE in "$@"; do
- [[ ! -f "$FILE" ]] && continue
- echo "Memproses: $(basename "$FILE")"
- # Ambil tinggi gambar untuk kalkulasi font (5.5%)
- HEIGHT=$(identify -format "%h" "$FILE")
- POINTSIZE=$(echo "$HEIGHT * 0.055" | bc | cut -d'.' -f1)
- OUTPUT="$(dirname "$FILE")/wm_$(basename "$FILE")"
- # Jalankan proses watermark (Shadow + Text)
- convert "$FILE" \
- \( -background none -fill "rgba(0,0,0,0.5)" -font "$FONT" -pointsize "$POINTSIZE" \
- label:"$TEXT" -rotate "$ROTATION" -blur 0x3 \) \
- -gravity center -geometry +4+4 -composite \
- \( -background none -fill "rgba(255,255,255,0.8)" -font "$FONT" -pointsize "$POINTSIZE" \
- label:"$TEXT" -rotate "$ROTATION" \) \
- -gravity center -composite \
- "$OUTPUT"
- if [ $? -eq 0 ]; then
- echo "✅ OK: $OUTPUT"
- else
- echo "❌ Gagal: $FILE"
- fi
- done
- yad --info --title="Selesai" --text="Watermark berhasil ditambahkan!" --timeout=3 --no-buttons
Add Comment
Please, Sign In to add comment