diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2022-11-03 14:37:05 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2022-11-03 14:37:05 +0100 |
commit | 97c1168f3edb31a28d7371332f80bb141c6e3721 (patch) | |
tree | 4b68000fae4483e89ce605df6c36b04db2c97b86 | |
parent | 7c2dab07b51336a671750871f78c3f1c42c35743 (diff) | |
download | scripts-97c1168f3edb31a28d7371332f80bb141c6e3721.tar.gz scripts-97c1168f3edb31a28d7371332f80bb141c6e3721.zip |
Created images scripts folder.
-rwxr-xr-x | images/genTile.sh | 61 |
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 +} |