How do I embed multiple sizes in an .ico file?

ImageMagick (Windows/Mac/Linux) contains a command-line tool called convert that can be used for many things, including packing multiple images in one icon:

convert 16.png 32.png 48.png 128.png 256.png -colors 256 icon.ico

The previous command takes 5 PNG images, and combines them into a single .ico file.

Unlike the other answers, this method can easily be used in batch scripts to automatically generate several icon files. In one of my projects, I have a single vector image (SVG), and use Inkscape to generate png's of various sizes, followed by convert to create a icon container. This is a reduced example (in a bash script):

#!/bin/bash
for size in 16 32 48 128 256; do
    inkscape -z -e $size.png -w $size -h $size icon.svg >/dev/null 2>/dev/null
done
convert 16.png 32.png 48.png 128.png 256.png -colors 256 icon.ico

Better command for ImageMagick:

convert in.jpg -define icon:auto-resize=16,48,256 -compress zip out.ico

You can do this for free in GIMP. There are brief instructions for doing this here.

To quote:

  1. Open your image in Gimp
  2. Make your canvas square
  3. Resize your layer to the image
  4. Scale the layer to the largest size in your .ico file like 64 pixels
  5. Duplicate the layer
  6. Scale the duplicate layer to the next size
  7. Keep duplicating / scaling for all the sizes you want in your .ico file
  8. Save as .ico

In your case, you could either start with the largest image and scale down for each duplicated image, or you could just add new layers and import the specific icon images you wanted into that layer.