From 97c1168f3edb31a28d7371332f80bb141c6e3721 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Thu, 3 Nov 2022 14:37:05 +0100 Subject: Created images scripts folder. --- images/genTile.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 images/genTile.sh (limited to 'images') 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 +} -- cgit v1.2.1