SVG is often the way to create an image, that format is scalable and easy to maintain. But still many applications need an icon *.ico. So it is necessary to convert the SVG to an icon. There are many online tools doing that, but I was not able to found any which can handle multiple resolutions in one ico-file. A icon normally can handle multiple resolutions in one single file. A icon is normally a square.

The resolutions are 16x16, 32x32, 48x48, 64x64, 128x128, 256x256, 512x512 and 1024x1024.

I used inkscape to create the SVG and export the PNG files with multiple resolutions, then I used magick to convert and merge the PNG files to one single ico file. My solution is based on the post on stackexchange - How to convert a square SVG to all-size ICO?.

Steps

  1. Download and Install the tools on your Windows system
  2. Create a SVG file and save it or use an existing one (double check that width and height are the same)
  3. Export the PNGs with inkscape CLI using the parameter --export-png
  4. Convert the PNGs to a single file icon with the convert option of magick
  5. Delete the temporary PNG files

Scripts

Use Inkscape with the --export-png command and call it in a loop over all resolutions. This will may waste a bit more of memory and executing time then the version with --shell.

@echo off
set svgfile="%~f1"
set path=%~dp1
set inkscape="C:\Program Files\Inkscape\inkscape.exe"

echo Start export svg %svgfile% to %path% using %inkscape% ...

for %%x in (16 32 48 64 128 256 512 1024) do (
    %inkscape% %svgfile% --export-png="%path%ico%%x.png" -w%%x -h%%x
)

echo ... export done.

Use Inkscape with the --shell command. Create a temporary file inkscapecommands.txt and hand it over to the inkscape exe. That shell parameter is not working for me.

@echo off
set svgfile="%~f1"
set path=%~dp1
set inkscape="C:\Program Files\Inkscape\inkscape.exe"
set tempinkscapefile=%~dp1/inkscapecommands.txt

echo Start export svg %svgfile% to %path% using %inkscape% ...

for %%x in (16 32 48 64 128 256 512 1024) do (
    echo %svgfile% --export-png="%path%ico%%x.png" -w%%x -h%%x >> %tempinkscapefile%
)
%inkscape% --shell < %tempinkscapefile%
erase "%tempinkscapefile%"

echo ... export done.

Call of the batch file ExportPNGsfromSVGWithInkscape.bat with the svg-filename as parameter. The PNGs will be dropped in the same folder like the SVG

ExportPNGsfromSVGWithInkscape.bat .\assets\KargWareLogo.svg

Call magick.exe with the convert option and the list of the PNGs (comma separated) and as last parameter the name of the new ico .\assets\KargWareLogo.ico

"c:\Program Files\ImageMagick-7.0.10-Q16\magick.exe" convert .\assets\ico16.png .\assets\ico32.png .\assets\ico48.png .\assets\ico64.png .\assets\ico128.png .\assets\ico256.png .\assets\ico512.png .\assets\ico1024.png .\assets\KargWareLogo.ico