Guest User

Untitled

a guest
Apr 11th, 2026
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Cek dependencies
  4. for cmd in convert yad fc-list bc; do
  5. if ! command -v $cmd >/dev/null 2>&1; then
  6. echo "Error: $cmd tidak ditemukan. Instal via sudo apt install imagemagick yad"
  7. exit 1
  8. fi
  9. done
  10.  
  11. # 1. Ambil input user sekaligus (Teks & Rotasi)
  12. user_input=$(yad --form --title="Watermark Settings" --width=350 --center \
  13. --field="Teks Watermark" "Sample Watermark" \
  14. --field="Rotasi:CB" "0!90!180!270")
  15.  
  16. [[ $? -ne 0 ]] && exit 1
  17.  
  18. TEXT=$(echo "$user_input" | cut -d'|' -f1)
  19. ROTATION=$(echo "$user_input" | cut -d'|' -f2)
  20.  
  21. # 2. Setup Font
  22. FONT="Noto-Sans-Casual"
  23. if ! fc-list | grep -qi "$FONT"; then
  24. FONT="Sans"
  25. fi
  26.  
  27. # 3. Proses File
  28. for FILE in "$@"; do
  29. [[ ! -f "$FILE" ]] && continue
  30.  
  31. echo "Memproses: $(basename "$FILE")"
  32.  
  33. # Ambil tinggi gambar untuk kalkulasi font (5.5%)
  34. HEIGHT=$(identify -format "%h" "$FILE")
  35. POINTSIZE=$(echo "$HEIGHT * 0.055" | bc | cut -d'.' -f1)
  36.  
  37. OUTPUT="$(dirname "$FILE")/wm_$(basename "$FILE")"
  38.  
  39. # Jalankan proses watermark (Shadow + Text)
  40. convert "$FILE" \
  41. \( -background none -fill "rgba(0,0,0,0.5)" -font "$FONT" -pointsize "$POINTSIZE" \
  42. label:"$TEXT" -rotate "$ROTATION" -blur 0x3 \) \
  43. -gravity center -geometry +4+4 -composite \
  44. \( -background none -fill "rgba(255,255,255,0.8)" -font "$FONT" -pointsize "$POINTSIZE" \
  45. label:"$TEXT" -rotate "$ROTATION" \) \
  46. -gravity center -composite \
  47. "$OUTPUT"
  48.  
  49. if [ $? -eq 0 ]; then
  50. echo "✅ OK: $OUTPUT"
  51. else
  52. echo "❌ Gagal: $FILE"
  53. fi
  54. done
  55.  
  56. yad --info --title="Selesai" --text="Watermark berhasil ditambahkan!" --timeout=3 --no-buttons
Add Comment
Please, Sign In to add comment