Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # @sevvie@collapse.pub:
- # > here’s the script. I named it lmao.sh.
- #!/bin/bash
- top_text="LMAO"
- bottom_text="BOTTOM TEXT"
- font=Impact
- fill=white
- stroke=black
- strokewidth=0
- caption_height=0
- usage() {
- echo "Usage: $0 [-t TOP_TEXT] [-b BOTTOM_TEXT] [-f FONT] [-l FILL_COLOR] [-s STROKE_COLOR] [-w STROKE_WIDTH] SRC DEST"
- }
- failure() {
- usage
- exit 1
- }
- while getopts "hb:t:f:l:s:w:" opt; do
- case ${opt} in
- b) bottom_text=$OPTARG;;
- t) top_text=$OPTARG;;
- f) font=$OPTARG;;
- l) fill=$OPTARG;;
- s) stroke=$OPTARG;;
- w) strokewidth=$OPTARG;;
- h) usage; exit 0;;
- :) failure;;
- *) failure;;
- esac
- done
- shift $((OPTIND -1))
- if [ -z $1 ] || [ -z $2 ]; then
- failure
- fi
- width=$(identify -format %w $1)
- height=$(identify -format %h $1)
- caption_height=$(echo "$width / 8" | bc)
- if [ "0" == $strokewidth ]; then
- strokewidth=$(echo "$width / 300" | bc)
- fi
- convert $1 \
- -background none \
- -font $font \
- -fill $fill \
- -stroke $stroke \
- -strokewidth $strokewidth \
- -size "${width}x${caption_height}" \
- -gravity north caption:"${top_text}" -composite \
- -gravity south caption:"${bottom_text}" -composite \
- $2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement