Feoh the Fitter»Blog

Setting the Exe icon

If you want to make your program look a bit more professional, one way is to set a icon on the exe, instead of the default icon.

Windows version:
  • Convert your logo image to .ico format. There are free online convertors that do the job.
  • Create a .rc file in your project. This is a script file windows will use to find out you want to set the icon.
  • In this file write: uniqueId ICON “./path/to/file.ico”
    Where the uniqueid is a name of your choosing.
  • You then compile this file using windows resource compiler, which takes .rc files and converts them to .res files. On the command line write: RC filename.rc where filename is the name of your .rc file you created.
  • Now that you have a .res file, you can pass this to the compiler when you compile your .exe. You just have to pass the path/to/file.res


Thats it! Now the exe should have a unique icon to make it look more professional.
Note: I believe the ico file is compiled in with the exe, so you don’t have to keep the .ico file around when you go to ship your program.

On mac it is also pretty simple. Mac differs in that you don’t actually change the icon of the executable, instead you set the icon for your .app bundle.
  • Convert your png image to .icns instead of .ico. I found the program Image2icon pretty good. And you just need the free version.
  • Put this file in the Resources folder of your bundle
  • A .app bundle has a file called Info.plist which is an XML file with meta data about your app. In this file there is an identifier that looks like this:
    <key>CFBundleIconFile</key>
    <string>iconfilename.icns</string>


For more info about the bundle structure on MacOS see

I found looking in the .app folder was the easiest way to work out how it works.




Mārtiņš Možeiko,
Oh there so much to do in your first "Convert your logo image to .ico format" step. What resolution to use, what format to use (RGB, index, etc..), keeping transparency, supporting multiple resolutions for hidpi screens, but keeping good quality for when icon needs to be displayed in smaller size, keeping small .ico size, etc...

.ico files can contain raw RGB data or indexed palette (just like bmp). Latter can produce smaller output if your icon doesn't have many different colors. .ico file also supports embedding .png files, which gives even smaller result than .bmp/.ico format.

I have not found good utility that does all this with good quality. Currently I use short python script that takes 32-bit RGBA png images as input and creates one multi-resolution .ico file. Because inputs I use are png images, the output is smaller than storing raw RGBA bytes in .ico file. Script is here: https://git.handmade.network/snippets/18 To use it, run
1
images2ico.py -o out.ico in1.png in2.png in3.png
I typically use 5 icons - 16x16, 32x32, 64x64, 128x128 and 256x256 (this last one is probably overkill, but whatever). Example of such icon is here. Only 77KB. Not bad, considering raw 32-bit RGBA 256x256 icon would be whole 256KB.

If size is an issue, especially when if you are creating tiny "handmade" style executables, then I keep only 16x16, 32x32, 48x48 and 64x64 sizes. Example of such icon is here. Only 1.3 KB. Full 64x64x4 icon would be 16KB.

Keeping smaller sizes explictly allows to create good looking quality in places where Windows uses smaller icon sizes, like window titlebar, Explorer list-view or similar. Default Windows resizing algorithm which it uses to get smaller icon from large icon is pretty bad.

Before using it on png files, I strip png files of any other unneeded extra metadata (comments, tags, etc...), to reduce final size. I use "pngcrush --brute -c 6 -d output_folder -rem alla input.png" or "optipng -dir output_folder -strip all -o7 input.png". Whatever gives smaller output.

More info on Window icons you can read here and here.
Oliver Marsh, Edited by Oliver Marsh on
Thanks Martins, i was hoping you would comment. Very helpful info, ill give your script a go.