Generate multiple PNG images with Inkscape SVG for Windows 10 Universal UWP apps with Powershell

I’ve been using Inkscape for many of my projects, it’s a great open source SVG vector editor. Windows Universal apps support scaling to pixel density for multiple resolutions. I made this Powershell script to generate PNGs scaled to multiple resolutions from your vector SVG files, so your app can look pretty at all resolutions. Using it is very easy:

  1. Make sure Inkscape is in the PATH
  2. In Inkscape create separate SquareLogo.svg and WideLogo.svg files, and size each document to fit the logo.
  3. Run the script, and it’ll produce about 30+ rescaled images that you can use in Visual Studio manifest editor.
# create a set of tiles for Universal Windows apps
# with Inkscape
# 1. Add Inkscape folder to PATH
# 2. place SquareLogo.svg, WideLogo.svg, Splash.svg into $dir
# images will appear in $outDir
$dir = "C:\svg"
$outDir = "C:\svg\images"

$squareSizes = @(71,89,150,107,142,284,600,300,150,225,188,1240,620,310,465,388,176,88,44,66,55,256,48,24,16,200,100,75,63,50)
$wideSizes = @(1240,620,310,465,388)
$splashSizes = @(2480,1240,930,775,620)

# square images
foreach($size in $squareSizes){
    $res = $outDir+"\"+"SquareLogo-"+$size+".png"
    inkscape --export-png $res -w $size $dir"\SquareLogo.svg"

# wide images
foreach($size in $wideSizes){
    $res = $outDir+"\"+"WideLogo-"+$size+".png"
    inkscape --export-png $res -w $size $dir"\WideLogo.svg"

# splash
foreach($size in $splashSizes){
    $res = $outDir+"\"+"Splash-"+$size+".png"
    inkscape --export-png $res -w $size $dir"\Splash.svg"