I don't know all-in-one solution, but I know two pieces that can be brought together:
- icoutils has
icotool
, which can create/extract .ico files.
- ImageMagick has
convert
, which can convert and resize the files to the desired sizes.
So, something like this will work (it may only work for files with ".png" extension):
#!/bin/bash
# Just pass the original .png image as the only parameter to this script.
SOURCE="$1"
BASE=`basename "${SOURCE}" .png`
convert "${SOURCE}" -thumbnail 16x16 "${BASE}_16.png"
convert "${SOURCE}" -thumbnail 32x32 "${BASE}_32.png"
convert "${SOURCE}" -thumbnail 48x48 "${BASE}_48.png"
convert "${SOURCE}" -thumbnail 64x64 "${BASE}_64.png"
icotool -c -o "${BASE}.ico" "${BASE}"_{16,32,48,64}.png
rm -f "${BASE}"_{16,32,48,64}.png
It's damn ugly, I know. But it is simple to understand, and it works (I tested it!). Just be careful, as it will create temporary files on current directory, and later delete them.