Skip to content

Instantly share code, notes, and snippets.

@kazkansouh
Created July 27, 2018 23:16
Show Gist options
  • Save kazkansouh/39e3dbaebfee8e0d56f333ad2fc9e1e2 to your computer and use it in GitHub Desktop.
Save kazkansouh/39e3dbaebfee8e0d56f333ad2fc9e1e2 to your computer and use it in GitHub Desktop.
Generate a range of PNG images of varying sizes from an SVG image
#! /bin/bash
WIDTHS="32 64 128 256 512 1024"
if test -z "$#" -o "$#" -ne 1 -o ! -f "$1" ; then
1>&2 echo "Usage: " `basename $0` " <SVGFILE>"
exit 1
fi
FILE=$1
BASENAME=`basename $1`
BASENAME=${BASENAME%.svg}
OUTDIR=${FILE%.svg}
mkdir -p ${OUTDIR}
for w in ${WIDTHS} ; do
echo "Processing width of $w"
inkscape -z -e ${OUTDIR}/${BASENAME}-${w}.png -w ${w} ${FILE}
done
echo done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment