aboutsummaryrefslogtreecommitdiff
path: root/images
diff options
context:
space:
mode:
Diffstat (limited to 'images')
-rwxr-xr-ximages/genTile.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/images/genTile.sh b/images/genTile.sh
new file mode 100755
index 0000000..66c89c0
--- /dev/null
+++ b/images/genTile.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# genTile.sh: Create a framed tile in the specified color
+#
+# Usage: genTile.sh [-s SIZE] COLOR
+
+usageMessage="Usage: ${0} [-s SIZE] COLOR"
+
+error() {
+ printf '%s error: %s\n' "$0" "$*" >&2
+}
+
+errorAndUsage() {
+ printf '%s error: %s\n%s\n' "$0" "$*" "$usageMessage" >&2
+}
+
+size=64
+borderSize=2
+
+# Process options
+while getopts ':s:' opt; do
+ case $opt in
+
+ 's' )
+ size="$OPTARG"
+ ;;
+
+ '?' )
+ printf '%s\n' "$usageMessage" >&2
+ exit 1
+
+ esac
+done
+shift $((OPTIND - 1))
+
+borderlessSize=$(( size - (borderSize * 2) ))
+color="$1"
+tmpFile="/tmp/${color}Temp.png"
+outputFile="${color}.png"
+
+[ -z "$color" ] && errorAndUsage "No color specified." && exit 1
+
+magick -size "${borderlessSize}x${borderlessSize}" "canvas:${color}" "$tmpFile" || exit 2
+convert "$tmpFile" -bordercolor black -border "${borderSize}x${borderSize}" "$outputFile" || exit 2
+
+
+#!/bin/sh
+
+# template.sh: A template for sh scripts
+#
+# Usage: template.sh [-ac] [-b OPTARG] FILE...
+
+usageMessage="Usage: ${0} [-ac] [-b OPTARG] FILE..."
+
+error() {
+ printf '%s error: %s\n' "$0" "$*" >&2
+}
+
+errorAndUsage() {
+ printf '%s error: %s\n%s\n' "$0" "$*" "$usageMessage" >&2
+}