Skip to content

Instantly share code, notes, and snippets.

@RajmohanKathiresan
Last active August 22, 2016 08:55
Show Gist options
  • Save RajmohanKathiresan/c8125414a871a0a14b1a2a3a4f8cea11 to your computer and use it in GitHub Desktop.
Save RajmohanKathiresan/c8125414a871a0a14b1a2a3a4f8cea11 to your computer and use it in GitHub Desktop.
SVG - PNG Script - Based on https://www.npmjs.com/package/svgexport
sourcepath="./SVG/"
destinationpath="./PNG/"
filestoprocess=(action_call_circle action_locate_circle action_settings_circle)
dimensionbyscale=false
dimensionpixel=($"40:" $"80:" $"120:")
dimensionscale=($"1x" $"2x" $"3x")
scaleprefix=($"" $"@2x" $"@3x")
for file in $sourcepath/*.svg; do
fullname=$(basename "$file")
extension="${fullname##*.}"
filename="${fullname%.*}"
if [[ " ${filestoprocess[@]} " =~ " ${filename} " ]]; then
pngextension=$".png"
quality=$"100%"
for index in ${!scaleprefix[*]}
do
pngfilename=$destinationpath$filename${scaleprefix[index]}$pngextension
#remove any file exists with the name before exporting
rm -f $pngfilename
if [ $dimensionbyscale == true ]
then
scalefactor=${dimensionscale[index]}
else
scalefactor=${dimensionpixel[index]}
fi
svgexport $sourcepath${fullname} ${pngfilename} ${quality} ${scalefactor}
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment