How to create a favicon for your site

Sun 16 December 2007

Favicon is a 16×16 bitmap in Microsoft icon resource file format. There are a lot of tools available to create a favicon.ico. I used GIMP, which is available for any linux/unix system or can be downloaded from http://www.gimp.org and can be also used on windows. So, first step is to rescale your image to 16x16 pixels and save your rescaled image in pnm or ppm format. Using the command line utility ppmtowinicon which is part of Netpbm package you can obtain the favicon:

ppmtowinicon -output favicon.ico \<inputfile.pnm | inputfile.ppm\>

The other method is to use convert command which is part of ImageMagick package. Since almost all Linux distributions install ImageMagick by default, all you need to generate your own favicon.ico is a shell access to a Linux box:

convert file.jpg -resize 16x16! favicon.ico

All you need now is to copy favicon.ico in your web site root folder and add to your webpage next line, to the \<head> section:

\<link rel="Shortcut Icon"
href="http://www.yourdomain.com/favicon.ico"\>

That's all.