how do I make a multi resolution .ico file?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
agent.coulson
Posts: 4
Joined: 2016-05-09T06:02:52-07:00
Authentication code: 1151

Re: how do I make a multi resolution .ico file?

Post by agent.coulson »

thanks, now with this command

Code: Select all

magick "%~1" -resize 256x256 -gravity center -extent 256x256 -define icon:auto-resize="256,128,96,64,48,32,16" "%~n1.ico"
i get this http://uptobox.com/0x6umc2kj8wd

Image

how to make the white color to tranparent?

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how do I make a multi resolution .ico file?

Post by fmw42 »

Code: Select all

magick "%~1" -resize 256x256 -gravity center -background none -extent 256x256 -define icon:auto-resize="256,128,96,64,48,32,16" "%~n1.ico"

agent.coulson
Posts: 4
Joined: 2016-05-09T06:02:52-07:00
Authentication code: 1151

Re: how do I make a multi resolution .ico file?

Post by agent.coulson »

thanks.. :D

Froschkoenig84
Posts: 1
Joined: 2019-06-06T20:17:23-07:00
Authentication code: 1152

Re: how do I make a multi resolution .ico file?

Post by Froschkoenig84 »

Windows batch file, which creates multiple sized .PNGs and merge them to one .ICO file:

Code: Select all

@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...

Code: Select all

del FILE
...or you save all PNGs inside a directory you can remove after...

Code: Select all

%imageMagick% %exportFileNames%"%~dp0%fileName%.ico"
Hope it helps somebody. :)

john1120
Posts: 11
Joined: 2017-05-31T04:29:13-07:00
Authentication code: 1151

Re: how do I make a multi resolution .ico file?

Post by john1120 »

I have tried solutions by GeeMack and fmw42, but neither works for me. What I'm doing wrong?

I run it as batch file:

Code: Select all

@echo off
setlocal
set IMDIR=C:\Program Files\ImageMagick-7.0.10-Q16

pushd "%~dp1"

"%IMDIR%\magick.exe" "%~1" -define icon:auto-resize="256,128,96,64,48,32,16" "%~n1.ico"

popd

@echo Done!
pause
exit
I paste it directly to cmd.exe:

Code: Select all

"C:\Program Files\ImageMagick-7.0.10-Q16\magick.exe" "%~1" -resize 256x256 -gravity center -background none -extent 256x256 -define icon:auto-resize="256,128,96,64,48,32,16" "%~n1.ico"

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how do I make a multi resolution .ico file?

Post by snibgo »

How do you run the batch file? What do you type at the command line?
snibgo's IM pages: im.snibgo.com

john1120
Posts: 11
Joined: 2017-05-31T04:29:13-07:00
Authentication code: 1151

Re: how do I make a multi resolution .ico file?

Post by john1120 »

@snibgo Hi.
How do you run the batch file? W
I save the batch file as "script.bat" in the same directory with two test images: image1.jpg and image2.png. The file generates the following error message:

Code: Select all

magick.exe: no decode delegate for this image format `' @ error/constitute.c/ReadImage/562.
What do you type at the command line?
I simply paste the one-linear from my previous post. It generates the following errors:

Code: Select all

magick.exe: unable to open image '%~1': No such file or directory @ error/blob.c/OpenBlob/3496.
magick.exe: no decode delegate for this image format `' @ error/constitute.c/ReadImage/562.
Of course, cmd.exe is open in the correct directory.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how do I make a multi resolution .ico file?

Post by snibgo »

When you run the batch script, what do you actually type at the command line?

The script expects the first argument to be the name of the file you want processed. Are you supplying that filename?

The one-liner you posted won't work if pasted at the command line, because it uses %~1 for the input file but %1 is the first argument to a script and you are not running a script.
snibgo's IM pages: im.snibgo.com

john1120
Posts: 11
Joined: 2017-05-31T04:29:13-07:00
Authentication code: 1151

Re: how do I make a multi resolution .ico file?

Post by john1120 »

The script expects the first argument to be the name of the file you want processed.
For some reason I expected it will process each image in the directory. That is, you don't need to add the filename.

Code: Select all

script.bat image.png
Now it works, thanks.

Locked