Languages
[Edit]
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
Created by:
Root-ssh
175020

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:
Y​​​​​ou should see in the same directory png files.

Note: do not forget to use squared svg icon. 

 

Svg icon exported to png files with Inkscape in Bash
Svg icon exported to png files with Inkscape in Bash

Inkscape installation

Download from:

 

Under Debian Linux run: apt-get install inkscape

 

Alternative titles

  1. Bash - export to png icons from svg file using Inkscape (sizes: 48 72 96 144 192 256 384 512)
  2. Bash - export to png icons from svg file using Inkscape (sizes: 48 72 96 144 192 256 384 512)
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Bash

Bash - batch export from svg to properly sized png file
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join