summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsvg2img60
1 files changed, 33 insertions, 27 deletions
diff --git a/svg2img b/svg2img
index 2dcf70e..41bad88 100755
--- a/svg2img
+++ b/svg2img
@@ -1,20 +1,22 @@
-#!/usr/bin/env bash
+#!/bin/sh
# Converts my logo to various formats from a template SVG
# Armaan Bhojwani 2021
-SIZES=(2048 1024 512 256 128 64)
-A_SIZES=(10 15 20 25 30 35 40 45 50 55 60)
+set -e
+
+SIZES="2048 1024 512 256 128 64"
+A_SIZES="10 15 20 25 30 35 40 45 50 55 60"
for arg in ${@};do
- [[ -z ${arg} ]] && echo "Please provide an output format!" && exit 1
+ [ -z ${arg} ] && echo "Please provide an output format!" && exit 1
- [[ ${arg} == "svg" ]] && find . -name *.svg -not -path "./template/*" \
+ [ ${arg} = "svg" ] && find . -name *.svg -not -path "./template/*" \
-exec rm -v {} \;
- if [[ (! -d "square/svg" || ! -d "circle/svg") || (${arg} == "svg") ]]; then
+ if [ ! -d "square/svg" ] || [ ! -d "circle/svg" ] || [ ${arg} = "svg" ]; then
echo "Generating SVGs"
for SHAPE in square circle; do
- mkdir -pv ${SHAPE}/svg
+ mkdir -p ${SHAPE}/svg
sed -e 's/STROKE/stroke="#00ffbf"/g' \
-e 's/FILL/#212121/g' template/${SHAPE}.svg \
@@ -54,19 +56,20 @@ for arg in ${@};do
done
fi
- [[ ${arg} == "svg" ]] && exit 0
+ [ ${arg} = "svg" ] && exit 0
- [[ ${arg} == "png" ]] && find . -name *.png -not -iwholename ./logo.png \
+ [ ${arg} = "png" ] && find . -name *.png -not -name ./logo.png \
-exec rm -v {} \;
- if [[ (! -d "square/png" || ! -d "circle/png") || (${arg} == "png") ]]; then
+ if [ ! -d "square/png" ] || [ ! -d "circle/png" ] || [ ${arg} = "png" ]; then
echo "Generating PNGs"
for SHAPE in square circle; do
- for i in ${SIZES[@]}; do
- mkdir -pv ${SHAPE}/png/${i}
+ set -- $SIZES
+ for i in $@; do
+ mkdir -p ${SHAPE}/png/${i}
done
- for i in ${SIZES[@]}; do
+ for i in $@; do
for SVGIN in square/svg/*; do
BASE=$(basename ${SVGIN} | cut -d '.' -f 1)
inkscape -w ${i} -h ${i} ${SVGIN} --export-filename \
@@ -82,14 +85,15 @@ for arg in ${@};do
done
fi
- [[ ${arg} == "png" ]] && exit 0
+ [ ${arg} = "png" ] && exit 0
- if [[ ${arg} == "ascii" ]]; then
+ if [ ${arg} = "ascii" ]; then
echo "Generating ASCII art"
find . -name *ascii.txt -exec rm -v {} \;
for SHAPE in square circle; do
- for i in ${A_SIZES[@]}; do
- mkdir -pv ${SHAPE}/ascii/${i}
+ set -- $A_SIZES
+ for i in $@; do
+ mkdir -p ${SHAPE}/ascii/${i}
for PNGIN in circle/png/2048/*; do
BASE=$(basename ${PNGIN} | cut -d '.' -f 1)
@@ -105,12 +109,13 @@ for arg in ${@};do
exit 0
fi
- if [[ ${arg} == "unicode" ]]; then
+ if [ ${arg} = "unicode" ]; then
echo "Generating Unicode"
find . -name *unicode.txt -exec rm -v {} \;
for SHAPE in square circle; do
- for i in ${A_SIZES[@]}; do
- mkdir -pv ${SHAPE}/unicode/${i}
+ set -- $A_SIZES
+ for i in $@; do
+ mkdir -p ${SHAPE}/unicode/${i}
for PNGIN in circle/png/2048/*; do
BASE=$(basename ${PNGIN} | cut -d '-' -f -4)
@@ -129,15 +134,16 @@ for arg in ${@};do
fi
for SHAPE in square circle; do
- find . -name *.${arg} -exec rm -v {} \;
+ find . -name '*.${arg}' -exec rm -v {} \;
- for i in ${SIZES[@]}; do
- mkdir -pv ${SHAPE}/${arg}/${i}
+ set -- $SIZES
+ for i in $@; do
+ mkdir -p ${SHAPE}/${arg}/${i}
done
-
- while read PAT; do
+
+ for PAT in $(find . -name '*.png' -not -name ./logo.png); do
echo "Generating ${arg}s"
- convert -verbose ${PAT} ${PAT//png/${arg}}
- done < <(find -name *.png -not -iwholename ./logo.png)
+ convert -verbose ${PAT} $(printf "%s" "$PAT" | sed "s/\.png/.$arg/g")
+ done
done
done