Advertisement
jncosideout

lmao.sh

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