favicon

A favicon is a special icon file (ICO) that uses a format borrowed from an unnamed :-) operating system platform. Despite its source many common browsers store the icons in bookmarks. Whenever a visitor bookmarks a site or creates a desktop shortcut to a site, it will use the favicon file to select an image contained inside the file to place beside the bookmark or shortcut.

All that is required on the site is to add something similar to

<link rel="shortcut icon" href="/favicon.ico" type="image/ico">

to the site.

ICO files contain multiple images which are automatically selectable by different applications according to their need. An ICO file can contain multiple images, in resolutions of 16×16, 24×24, 32×32, and 48×48, each with either 16 or 256 colors.

I am using netpbm to create ICO files. The following script takes a ppm, pgm, pbm, or pam file and creates a favicon.ico file in all possible resolutions and all possible color depths:

#!/bin/sh
for size in 16 24 32 48
do
        for color in 16 256
        do
                pnmscale -xsize $size -ysize $size $1 >favicon-$size-.ppm
                pnmcolormap $color favicon-$size-.ppm >favicon--$color.ppm
                pnmremap -mapfile=favicon--$color.ppm favicon-$size-.ppm >favicon-$size-$color.ppm
                rm -f favicon-$size-.ppm favicon--$color.ppm
                ff="$ff favicon-$size-$color.ppm"
        done
done
ppmtowinicon $ff >favicon.ico

Note that the input file should have square format, otherwise the aspect ratio will be distorted.


automagically generated for 38.103.63.59 at 13 Oct 2008 08:49:36 CEST
last modified by myself at 23 Feb 2006 07:57:03 CET
accessed 4044 times since 27 Aug 2003 21:23:26 CEST
validated HTML 4.01