Recipe for creating Windows ICO files with ImageMagick?

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?".
Post Reply
pypt
Posts: 2
Joined: 2012-07-17T09:36:37-07:00
Authentication code: 15

Recipe for creating Windows ICO files with ImageMagick?

Post by pypt »

I would like to create .ico icon for my Windows application dynamically (from the SVG file) by using ImageMagick. The icon should be created according to the Microsoft recommendations [1] [2] regarding application icons (different sizes, depths, and an additional hi-res PNG icon for Vista+ in a single .ico). How do I do that? Does anyone has a ready-made recipe?

Microsoft lists various color depth and size requirements [1] for the icon. ImageMagick has the -depth and -colors options, but I'm not sure how to use them correctly in this case.

Additionally, it looks like Vista+ supports 256x256 hi-res icon [2] embedded into the very same .ico which can (should? must?) be a compressed PNG. How do I "join" the Windows XP icons and this new Vista icon into a single .ico file?

[1]: http://msdn.microsoft.com/en-us/library ... cons_step5
[2]: http://msdn.microsoft.com/en-us/library ... .aspx#size
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Recipe for creating Windows ICO files with ImageMagick?

Post by glennrp »

Assuming you've already got the images, this should do it:
  • convert vista.ico image_256x256 combined.ico
Note that the 256x256 image can be in any format.

There's a bug in ImageMagick-6.7.8-3 that causes it to not do PNG encoding
of the 256x256 image. That's fixed in the forthcoming ImageMagick-6.7.8-4.
pypt
Posts: 2
Joined: 2012-07-17T09:36:37-07:00
Authentication code: 15

Re: Recipe for creating Windows ICO files with ImageMagick?

Post by pypt »

Thanks!

However, how to I create those images with correct sizes and depths from a, say, PNG? Again, I've tried -depth option without much luck (for example, -depth 4 does not provide a 4-bit ICO as required by Windows XP).

I did a "correct" version of the icon with a proprietary application [1]. How do I reproduce that with IM?

[1]: http://stuff.pypt.lt/icon-win32.ico
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Recipe for creating Windows ICO files with ImageMagick?

Post by glennrp »

pypt wrote:Thanks!

However, how to I create those images with correct sizes and depths from a, say, PNG? Again, I've tried -depth option without much luck (for example, -depth 4 does not provide a 4-bit ICO as required by Windows XP).
Looking at the source for coders/icon.c, it appears that one can control the depth with the -colors option together with the -depth option (e.g., -colors 16 -depth 4 to get a 4-bit ICO). I tried that and identify -verbose tells me that it works.
Post Reply