Languages
[Edit]
EN

Bash - batch export from svg to properly sized png file (squared web page icon in pixels: 48 72 96 144 192 256 384 512)

2 points
Created by:
Root-ssh
6631

In this short article we are going to look at how quickly and in autmated way, export some svg file to png icon with Bash and Inkscape.

Note: check that you have installed Inscpage:

Do following steps: 

1. Create export.sh file:

#!/bin/bash

icon="icon.svg"                                    # input icon

program="inkscape"                                 # for linux
#program="/C/Program Files/Inkscape/inkscape.exe"  # for windows x64

for i in 48 72 96 144 192 256 384 512;
do
        "${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 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
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.