This project has moved and is read-only. For the latest updates, please go here.

How to convert a single PNG to multi-resolution (multi size) ICO?

Jan 21, 2016 at 12:40 AM
Edited Jan 21, 2016 at 2:18 AM
I successfully converted PNG image to ICO using this code:
using (var magic = new MagickImage(convertImagePath))
But I found that the ICO file has only 1 resolution which is the same with the original PNG. Can I convert PNGs to have a multiple-sized ICO file? Also the PNG file has transparent background and I'm also expecting that the result multi-size ICO file is also transparent.
Jan 21, 2016 at 12:06 PM
You could resize your input image an put all the images in a MagickCollection and write that to your output file. But it is easier to use a builtin feature of ImageMagick for that.
using (var image = new MagickImage(convertImagePath))
  image.SetDefine(MagickFormat.Icon, "auto-resize", "64,48,32,16");
This will write an multi-sized icon that contains the dimensions 64x64, 48x48, 32x32, 16x16. Make sure your input image is square already.