Windows batch file, which creates multiple sized .PNGs and merge them to one .ICO file:
@echo off
set inkScape="C:\SOFTWARE\GRAPHIC\INKSCAPE\inkscape.exe"
set imageMagick="C:\SOFTWARE\DEVELOPER\IMAGEMAGICK\magick.exe"
set fileName=favicon
set importType=svg
set exportType=png
set exportDpi=300
set imageSizes=(16 24 32 48 57 60 64 70 72 76 96 114 120 128 144 150 152 180 192 196 256 300 320 400 450 460 480 512 600)
for %%s in %imageSizes% do (
%inkScape% -z -f %~dp0%fileName%.%importType% -w %%s -h %%s -e %~dp0%fileName%-%%sx%%s.%exportType% -d %exportDpi%
echo CREATED: %fileName%-%%sx%%s.%exportType%
set e=%fileName%-%%sx%%s.%exportType%
call :concat (e)
)
%imageMagick% %exportFileNames%"%~dp0%fileName%.ico"
echo MERGED IN: %fileName%.ico
pause goto :eof
:concat (e) (
set exportFileNames=%exportFileNames%"%~dp0%e%"
)
If you don't need the .PNG files, you can delete (or remove) them by del FILE
or you save all PNGs inside a directory you can remove (after %imageMagick% %exportFileNames%"%~dp0%fileName%.ico"
).
Hope it helps somebody. :)
How do you do the opposite? Convert a
.ico
into multiple PNGs, based on the sizes it contains? – Flimm – 2014-07-09T09:38:19.5002@Flimm
convert favicon.ico favicon.png
generatesfavicon-0.png
,favicon-1.png
, etc. for every icon in the frame. If you want to know the dimensions of the image, use theidentify
command on the png file. – Rob W – 2014-07-09T09:41:29.407You can use imagemagicks own
convert <icon.png> -resize 64x64
instead of inkscape – kumarharsh – 2016-02-17T06:03:58.730I added
-dither None
to the convert command because the default conversion to 256 colors added some noise to my icon – James Roth – 2017-11-19T00:07:45.483@RobW I tried this and have been having problems with setting the small icon. When I check it still displays the default icon. – Kennichi Nitta – 2020-01-02T02:06:15.373
1Man, I feel like I learn a new way to use ImageMagick's
convert
every time I look into it. Thanks for the answer! – Suchipi – 2013-12-02T23:33:18.030