Created
June 16, 2016 22:56
-
-
Save kmosher/9efbf83cc985050d13078dc990bec5a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
set -e | |
setopt extendedglob | |
o_font=(--font /Library/Fonts/Impact.ttf) | |
o_pointsize=(--pointsize 42) | |
o_remote=(--remote "people.yelpcorp.com:public_html/dockercats/") | |
o_identity=(--identity "dockercats") | |
o_irc=(--irc) | |
o_tumblr=() | |
o_fight=() | |
zparseopts -K -D -E -- -font:=o_font -pointsize:=o_pointsize -remote:=o_remote -identity:=o_identity -irc:=o_irc -tumblr=o_tumblr -fight=o_fight | |
font=${o_font[2]} | |
pointsize=${o_pointsize[2]} | |
remote=${o_remote[2]} | |
identity=${o_identity[2]} | |
irc=${o_irc[2]} | |
tumblr=${o_tumblr[1]} | |
fight=${o_fight[1]} | |
source="$1" | |
top_text= | |
bottom_text= | |
if [ -z "$3" ]; then | |
bottom_text="$2" | |
else | |
top_text="$2" | |
bottom_text="$3" | |
fi | |
dest="$(dirname "${source}")"/captioned/"${top_text//[^[:alnum:]]##/-}${bottom_text//[^[:alnum:]]##/-}.${source##*.}" | |
if [ ! -d "$(dirname ${dest})" ]; then | |
mkdir -v "$(dirname ${dest})" | |
fi | |
if [ -n "$fight" ]; then | |
convert -pointsize "${pointsize}" -font "${font}" \ | |
-stroke black -fill white -strokewidth 3 \ | |
\( "${source}[0-7]" \ | |
-gravity NorthEast -draw "text 5,0 '${top_text}'" \) \ | |
\( "${source}[8-15]" \ | |
-gravity SouthWest -draw "text 8,0 '${bottom_text}'" \) \ | |
\( "${source}[16-23]" \ | |
-gravity NorthEast -draw "text 5,0 '${top_text}'" \) \ | |
\( "${source}[24-31]" \ | |
-gravity SouthWest -draw "text 8,0 '${bottom_text}'" \) \ | |
-loop 0 "${dest}" | |
else | |
convert "${source}" -pointsize "${pointsize}" -font "${font}" \ | |
-stroke black -fill white -strokewidth 3 \ | |
-gravity North -annotate 0 "${top_text}" \ | |
-gravity South -annotate 0 "${bottom_text}" \ | |
-loop 0 "${dest}" | |
#convert -pointsize "${pointsize}" -font "${font}" \ | |
# -stroke black -fill white -strokewidth 3 \ | |
# \( "${source}[0-12]" -gravity North -annotate 0 "${top_text}" \) \ | |
# \( "${source}[13-16]" -gravity South -annotate 0 "${bottom_text}" \) \ | |
# -loop 0 "${dest}" | |
# | |
fi | |
open "${dest}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment