Are there any command line utilities for Linux (or other Unix-like OS) which can:

  • Generate an .ico file with multiple icons in it
  • Do it from only 1 (one) png or jpeg image

For example:

% cool_icon_maker myimage_128x128.png file.ico

In file.ico there should automatically be all the icon sizes like 128x128, 64x64, 32x32, 16x16, etc.

up vote 7 down vote accepted

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.

I don't think there is, but it probably would be a couple of lines script using "convert".

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.