: How to convert a square SVG to all-size ICO? 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,
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)?
More posts by @Samaraweera207
3 Comments
Sorted by latest first Latest Oldest Best
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 FilesInkscapeinkscape.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
You can use ImageMagick right away:
convert -density 384 icon.svg -define icon:auto-resize icon.ico
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
...
3) Convert the PNG images to ICO:
magick convert 16.png 32.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
...
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.