diff options
author | Baudouin Roullier | 2016-11-27 21:07:17 +0100 |
---|---|---|
committer | Baudouin Roullier | 2016-11-27 21:07:17 +0100 |
commit | 4d0c0a19e4dfdd01eab5e5df29a4d8e099702066 (patch) | |
tree | bd34d778d793c30085d93d962fca7ef146a837fc | |
download | aur-4d0c0a19e4dfdd01eab5e5df29a4d8e099702066.tar.gz |
Adding first files
-rw-r--r-- | .SRCINFO | 15 | ||||
-rw-r--r-- | PKGBUILD | 17 | ||||
-rwxr-xr-x | shitpost | 101 |
3 files changed, 133 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..6e2c5f060106 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,15 @@ +pkgbase = shitpost + pkgdesc = A tool to create memes using CLI + pkgver = 1 + pkgrel = 1 + url = https://redd.it/5ezk1f + arch = i686 + arch = x86_64 + license = unknown + depends = imagemagick + depends = ttf-ms-fonts + noextract = shitpost + md5sums = 7ed84dc6ec3a3593153520050be3ba50 + +pkgname = shitpost + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..9c4b0f6db7c8 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,17 @@ +# Maintainer: Baudouin Roullier <DISGUISE baudouin dot roullier at gmail dot com DISGUISE> +# Originally by Mykal Anderson +pkgname=('shitpost') +pkgver=1 +pkgrel=1 +pkgdesc="A tool to create memes using CLI" +arch=('i686' 'x86_64') +license=('unknown') +url="https://redd.it/5ezk1f" +depends=('imagemagick' 'ttf-ms-fonts') +noextract=('shitpost') +md5sums=('7ed84dc6ec3a3593153520050be3ba50') + +package() { + mkdir -p "${pkgdir}/usr/bin/" + install -D -m755 shitpost "${pkgdir}/usr/bin/" +} diff --git a/shitpost b/shitpost new file mode 100755 index 000000000000..5e490911374e --- /dev/null +++ b/shitpost @@ -0,0 +1,101 @@ +#!/bin/bash + +#someone on /r/linuxmasterrace asked what image programs were good for shitposts +#it got me thinking that there should be a cli command just for that +#days later (I'm still pretty noob)... + +#SHITPOST +#Takes an image and adds some shitty text to it + +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +# Version 2, December 2004 +#Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> +#Everyone is permitted to copy and distribute verbatim or modified +#copies of this license document, and changing it is allowed as long +#as the name is changed. +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +#TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +# 0. You just DO WHAT THE FUCK YOU WANT TO. + +#Originally by Mykal Anderson + + + +#Begin + +#Check if imagemagick (just convert checked, but others used) is installed and exit if missing + +command -v convert >/dev/null 2>&1 || { echo >&2 "I require ImageMagick but it's not installed. Aborting."; exit 1; } + +#Get CLI args + +OPTIND=1 + +top_text=" " +bottom_text=" " +image_file="" + +while getopts "h?t:b:f:" opt; do + + case "$opt" in + h|\?) + printf "Available options are:\n t - Top Text\n b - Bottom Text\n f - Path to image file - Mandatory!\n" + exit 0 + ;; + t) top_text="$OPTARG" + ;; + b) bottom_text="$OPTARG" + ;; + f) image_file="$OPTARG" + ;; + esac +done + +shift $((OPTIND-1)) + +[ "$1" = "--" ] && shift + +#Make sure an image file was set and that it exists, or, what are we doing here, really. (Does not successfully check when source is a URL that fails to load, https for example) Would like to confirm it's an image file convert will take too but... +if [ -z "$image_file" ] + then echo "You must specify an image file. Use -h or -? for help."; exit 1 +fi + +#Let the user know any options that were invalid that were not allready handled by getopts. +if [ ! -z "$@" ] + then printf "Invalid arguement(s): \"$@\"\nIgnored, continuing...\n" +fi + +#Get some info on the file path etc +path=${image_file%/*} +base=${image_file##*/} +fext=${base##*.} +pref=${base%.*} + +#Upscale the image if it's too shitty. This is required to make the text readable as it's generated to fit the pixels of the original +convert -resize 1024x1024\< "$image_file" shitpost-temp-resize.gif + +#Get the height and width of the image to use later to size the overlays. Clipped height keeps things locked in the top and bottom fifth of the image. +image_width=`identify -format "%[width]" shitpost-temp-resize.gif` +image_height=`identify -format "%[height]" shitpost-temp-resize.gif` +clipped_height=$(($image_height/5)) +stroke_width=$(($clipped_height/40)) + + +convert -background none -fill white -stroke black -strokewidth "$stroke_width" -size "$image_width"x"$clipped_height" -gravity Center -font 'Impact' caption:"$top_text" temp-top-text.gif +convert -background none -fill white -stroke black -strokewidth "$stroke_width" -size "$image_width"x"$clipped_height" -gravity Center -font 'Impact' caption:"$bottom_text" temp-bottom-text.gif +composite -gravity north temp-top-text.gif shitpost-temp-resize.gif shitpost-temp-composite.gif +composite -gravity south temp-bottom-text.gif shitpost-temp-composite.gif shitpost-"$pref"."$fext" + + +#Clean up +rm temp-top-text.gif +rm temp-bottom-text.gif +rm shitpost-temp-resize.gif +rm shitpost-temp-composite.gif + +#Announce the results +echo "Created file "$PWD"/shitpost-"$pref"."$fext"" + +exit 0 + +#End
\ No newline at end of file |