I've drawn an icon in InkScape and would like to export it to an ICO file that would include sprites for all the reasonable resolutions (16x16, 32x32, ... 256x256 etc). How can this be done (without using huge and expensive software like Photoshop, CorelDraw etc)?

  • 2
    A quick search tells me there is no way to export even a single ICO out of InkScape, but there are lots of suggestions on how to do so with additional - free - software such as GIMP. Did you check those options? If they did not work for you, can you tell why not? – usr2564301 Sep 11 '16 at 19:59
  • @RadLexus what I have tried is a number of online tools and all of them, as far as I could understand, mean to create single-size ICOns. – Ivan Sep 11 '16 at 21:59
  • 5
    So you want to know how to create multiple-size ICOs? Try the options in this Stack Overflow answer: stackoverflow.com/questions/4354617/… (again, found by a simple Google query...). – usr2564301 Sep 11 '16 at 22:46
  • 1
    There is an Inkscape extension which seems to export as ico file, but I have no time at the moment to try if it works. – Paolo Gibellini Sep 12 '16 at 13:29
  • If you've found any of the below to answer your question please mark it as the accepted answer. – Mᴏɴᴋᴇʏ May 31 at 14:07

You can use ImageMagick right away:

convert -density 384 icon.svg -define icon:auto-resize icon.ico
  • 1
    Why that density? – naught101 Nov 21 at 5:54
  • I don't know, I just copy-pasted this from elsewhere. – heltonbiker Nov 21 at 13:47

A command line solution:

1) Export your SVG to PNG with InkScape

2) Resize this PNG image to the sizes you want with ImageMagick:

magick convert master.png -resize 16x16 16.png
magick convert master.png -resize 32x32 32.png
magick convert master.png -resize 48x48 48.png

3) Convert the PNG images to ICO:

magick convert 16.png 32.png 48.png icon.ico

4) Make sure your ICO contains everything:

identify icon.ico
icon.ico[1] ICO 16x16 16x16+0+0 32-bit sRGB 21.2KB 0.000u 0:00.000
icon.ico[0] ICO 32x32 32x32+0+0 32-bit sRGB 21.2KB 0.000u 0:00.000
icon.ico[0] ICO 48x48 48x48+0+0 32-bit sRGB 21.2KB 0.000u 0:00.000
  • You can also use a simple batch or shell file in order to simplify the work. – Paolo Gibellini Sep 14 '16 at 12:25
  • 1
    Wouldn't it be better (even if a little more complicated) to export the many png sizes directly from SVG instead of resizing already rasterized PNGs? – heltonbiker Nov 28 '17 at 13:19
  • 1
    Just in case anyone else is curious, the "..." is not literal. It represents other png file sizes to cram into the favicon.ico file. – Nostalg.io Sep 14 at 6:32
  • @Nostalg.io Good remark, thanks! I edited the answer. – philippe_b Sep 14 at 6:35

I would suggest this approach:

1) create a script to export the SVG to any required size. I've coded this .bat script to help me create an Android icon

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

echo Le icone saranno salvate in %path%
echo Produzione icone applicative

echo %file% --export-png="%path%/ic32.png" -w32 -h32 > %~dp1/commands.txt
echo %file% --export-png="%path%/ic48.png" -w48 -h48 > %~dp1/commands.txt
echo %file% --export-png="%path%/ic72.png" -w72 -h72 > %~dp1/commands.txt
echo %file% --export-png="%path%/ic96.png" -w96 -h96 > %~dp1/commands.txt
echo %file% --export-png="%path%/ic144.png" -w144 -h144 > %~dp1/commands.txt
echo %file% --export-png="%path%/ic192.png" -w192 -h192 > %~dp1/commands.txt
echo %file% --export-png="%path%/ic512.png" -w512 -h512 > %~dp1/commands.txt
%inkscape% --shell < %~dp1/commands.txt
erase "%~dp1/commands.txt"

echo Procedura terminata

NOTE:

  • the defined %inkscape% var should be adequate to your Inkscape install path
  • the script echoes all export commands to a temp file to a better management of inkscape process. The "shell" cli param accepts more commands using a single instance instead of spawn an instance per command.

With this parameter, Inkscape will enter an interactive command line shell mode. In this mode, you type in commands at the prompt and Inkscape executes them, without you having to run a new copy of Inkscape for each command. This feature is mostly useful for scripting and server uses: it adds no new capabilities but allows you to improve the speed and memory requirements of any script that repeatedly calls Inkscape to perform command line tasks (such as export or conversions). Each command in shell mode must be a complete valid Inkscape command line but without the Inkscape program name, for example "file.svg --export-pdf=file.pdf". (see inkscape manual)

2) Add to the above script the convert syntax stated in philippe-b answer which merges all the generated PNGs to a single ICO file

3) Optionally, remove all exported PNGs as they are no more needed

Bash version...

#!/bin/bash

set -ex

svg=$1

size=(16 32 24 48 72 96 144 152 192 196)

echo Making bitmaps from your svg...

for i in ${size[@]}; do
  inkscape $svg --export-png="favicon-$i.png" -w$i -h$i --without-gui
done

echo Compressing...

## Replace with your favorite (e.g. pngquant)
# optipng -o7 favicon-*.png
pngquant -f --ext .png favicon-*.png --posterize 4 --speed 1

echo Converting to favicon.ico...

convert $(ls -v favicon-*.png) favicon.ico

## Clean-up maybe?
# rm favicon-*.png

echo Done

Usage: ./favicon.sh your-square-svg-file.svg

Requires: inkscape imagemagick optipng (optional) from your package manager.

I found it easier to re-create this for the bash shell since Win10 and Inkscape weren't getting along. This was tested within Windows Subsystem for Linux but it should also work on Mac.

Used this reference to choose the sizes I cared about: https://github.com/audreyr/favicon-cheat-sheet. Adjust the size array to your specific needs.

This website is my go to for favicon generation as it includes the icons for the Add To Homescreen for most devices (Windows, macOS, Android, iOS) https://realfavicongenerator.net/

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.