EN
Bash - batch export from svg to properly sized png file using Inkscape (squared web page icon in pixels: 48 72 96 144 192 256 384 512)
11
points
In this short article, we are going to look at how quickly and in an automated way, export some SVG files to PNG icons with Bash and Inkscape.
Practical example
Do the following steps:
1. Create export.sh
file:
#!/bin/bash
icon="icon.svg" # input icon
# program="/C/Program Files/Inkscape/bin/inkscape.exe" # for windows x64
# program="/C/Program Files/Inkscape/inkscape.exe" # for windows x64
program="inkscape" # for linux
for i in 48 72 96 144 192 256 384 512;
do
"${program}" --export-type="png" --export-filename="./icon-${i}x${i}.png" -w "${i}" -h "${i}" "${icon}"
# "${program}" -z -e "./icon-${i}x${i}.png" -w "${i}" -h "${i}" "${icon}";
done
2. Add permissions for script if it is necessary:
chmod +x export.sh
3. Run export.sh
:
./export.sh
4. Result:
You should see in the same directory png files.
Note: do not forget to use squared svg icon.
Inkscape installation
Download from:
Under Debian Linux run: apt-get install inkscape