Advertisement
jncosideout

lmao.sh

Feb 27th, 2024
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.19 KB | None | 0 0
  1. # @sevvie@collapse.pub:
  2. # > here’s the script. I named it lmao.sh.
  3.  
  4. #!/bin/bash
  5.  
  6. top_text="LMAO"
  7. bottom_text="BOTTOM TEXT"
  8. font=Impact
  9. fill=white
  10. stroke=black
  11. strokewidth=0
  12. caption_height=0
  13.  
  14. usage() {
  15.   echo "Usage: $0 [-t TOP_TEXT] [-b BOTTOM_TEXT] [-f FONT] [-l FILL_COLOR] [-s STROKE_COLOR] [-w STROKE_WIDTH] SRC DEST"
  16. }
  17.  
  18. failure() {
  19.   usage
  20.   exit 1
  21. }
  22.  
  23. while getopts "hb:t:f:l:s:w:" opt; do
  24.   case ${opt} in
  25.     b) bottom_text=$OPTARG;;
  26.     t) top_text=$OPTARG;;
  27.     f) font=$OPTARG;;
  28.     l) fill=$OPTARG;;
  29.     s) stroke=$OPTARG;;
  30.     w) strokewidth=$OPTARG;;
  31.     h) usage; exit 0;;
  32.     :) failure;;
  33.     *) failure;;
  34.   esac
  35. done
  36.  
  37. shift $((OPTIND -1))
  38.  
  39. if [ -z $1 ] || [ -z $2 ]; then
  40.   failure
  41. fi
  42.  
  43. width=$(identify -format %w $1)
  44. height=$(identify -format %h $1)
  45. caption_height=$(echo "$width / 8" | bc)
  46. if [ "0" == $strokewidth ]; then
  47.   strokewidth=$(echo "$width / 300" | bc)
  48. fi
  49.  
  50. convert $1 \
  51.   -background none \
  52.   -font $font \
  53.   -fill $fill \
  54.   -stroke $stroke \
  55.   -strokewidth $strokewidth \
  56.   -size "${width}x${caption_height}" \
  57.     -gravity north caption:"${top_text}" -composite \
  58.     -gravity south caption:"${bottom_text}" -composite \
  59.   $2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement