diff options
author | Connor Behan | 2015-06-08 21:08:50 -0400 |
---|---|---|
committer | Connor Behan | 2015-06-08 21:08:50 -0400 |
commit | cf99c0043807ba224d79fbb3f8a3eafef700a4a3 (patch) | |
tree | 09997c54dcdec5da508ca4557a6ab1badc6d5278 | |
download | aur-cf99c0043807ba224d79fbb3f8a3eafef700a4a3.tar.gz |
Initial import
-rw-r--r-- | .SRCINFO | 16 | ||||
-rw-r--r-- | PKGBUILD | 20 | ||||
-rw-r--r-- | mememaker | 85 |
3 files changed, 121 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..d026d64e03b0 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,16 @@ +pkgbase = mememaker-quiet + pkgdesc = Non-interactive version of mememaker with no bundled images + pkgver = 2.0.0 + pkgrel = 1 + url = http://www.reddit.com/r/ScriptSwap/comments/r1oxf/bash_meme_maker_script_creates_meme_in_terminal/ + arch = any + license = GPL + depends = imagemagick + depends = ttf-ms-fonts + provides = mememaker + conflicts = mememaker + source = mememaker + md5sums = be8d9536805fb1bf6d3e5ef11d3464a0 + +pkgname = mememaker-quiet + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..392bfcc65098 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,20 @@ +# Contributor: Connor Behan <connor.behan@gmail.com> + +pkgname=mememaker-quiet +pkgver=2.0.0 +pkgrel=1 +pkgdesc="Non-interactive version of mememaker with no bundled images" +arch=('any') +url="http://www.reddit.com/r/ScriptSwap/comments/r1oxf/bash_meme_maker_script_creates_meme_in_terminal/" +depends=('imagemagick' 'ttf-ms-fonts') +conflicts=('mememaker') +provides=('mememaker') +license=('GPL') +source=(mememaker) + +package() { + install -d "$pkgdir"/usr/bin + install -Dm755 "$srcdir"/mememaker "$pkgdir"/usr/bin/ +} + +md5sums=('be8d9536805fb1bf6d3e5ef11d3464a0') diff --git a/mememaker b/mememaker new file mode 100644 index 000000000000..7a1cfba32f0a --- /dev/null +++ b/mememaker @@ -0,0 +1,85 @@ +#!/bin/bash + +usage() { + echo -e "-h --help display this message" + echo -e "-m --meme <file> create a meme from an image" + echo -e "-s --split <file1> <file2> create a split meme with file1 on top and file2 on bottom" + echo -e "-t --top <text> set top text" + echo -e "-b --bottom <text> set bottom text" + echo -e "-o --output <file> png file for output (left as /tmp/out.png if absent)" +} + +create_meme() { + width="$(identify -format %w /tmp/out.png)" + height="$(identify -format %h /tmp/out.png)" + + letters_per_line="$(($width/16))" + top="$(echo $top | fold -s -w $letters_per_line)" + bottom="$(echo $bottom | fold -s -w $letters_per_line)" + + [[ -n "$bottom" ]] && convert -font /usr/share/fonts/TTF/impact.ttf -pointsize 35 \ + -background '#0000' -fill white -stroke black -strokewidth 2 \ + -gravity south -size ${width}x${height} label:"$bottom" /tmp/out.png +swap \ + -gravity center -composite /tmp/out.png + [[ -n "$top" ]] && convert -font /usr/share/fonts/TTF/impact.ttf -pointsize 35 \ + -background '#0000' -fill white -stroke black -strokewidth 2 \ + -gravity north -size ${width}x${height} label:"$top" /tmp/out.png +swap \ + -gravity center -composite /tmp/out.png +} + +while : +do + case $1 in + -h | --help) + usage + exit 0;; + -m | --meme) + if [[ -n "$2" && "${2:0:1}" != "-" && -f "$2" ]]; then + convert "$2" -adaptive-resize "600x" /tmp/out.png + shift 2 + else + usage + exit 0 + fi;; + -s | --split) + if [[ -n "$2" && "${2:0:1}" != "-" && -f "$2" && -n "$3" && "${3:0:1}" != "-" && -f "$3" ]]; then + convert -crop 100%x50% "$2" /tmp/"meme_top"%d.png + convert -crop 100%x50% "$3" /tmp/"meme_bottom"%d.png + convert -append -adaptive-resize "600x" /tmp/"meme_top"0.png /tmp/"meme_bottom"1.png /tmp/out.png + rm /tmp/"meme_top"0.png /tmp/"meme_top"1.png /tmp/"meme_bottom"0.png /tmp/"meme_bottom"1.png + shift 3 + else + usage + exit 0 + fi;; + -t | --top) + if [[ -n "$2" && "${2:0:1}" != "-" ]]; then + top="$2" + shift 2 + else + usage + exit 0 + fi;; + -b | --bottom) + if [[ -n "$2" && "${2:0:1}" != "-" ]]; then + bottom="$2" + shift 2 + else + usage + exit 0 + fi;; + -o | --output) + if [[ -n "$2" && "${2:0:1}" != "-" && -d $(dirname "$2") ]]; then + outfile="$2" + shift 2 + else + usage + exit 0 + fi;; + *) + break;; + esac +done + +[[ -f /tmp/out.png ]] && create_meme +[[ -n "$outfile" ]] && mv /tmp/out.png "$outfile" |