Jan 242000
 

favicon.ico

If you run a web server, no doubt you’ve seen entries in your logs like this:
"GET /favicon.ico HTTP/1.1" 404 3711

That bothered me for quite some time.  Then I went searching to find an answer.   I found it at http://www.favicon.com/.

See also Putting the Daemon into Windows.

And don’t forget to read How to create favicon-icons on Unix machines.

What is it?

This is an advanced browser feature.  It allows for an icon pertaining to the site to be recorded against your bookmark.  That”s quite nice, but some browsers seem to request a favicon from each and every page they visit.  That is not nice.  But I’ve caved in and I’ve given up.  I have to have a favicon.ico.   My nerves are running ragged from seeing that message in my error logs.  I awake in the middle of the night wondering how to fix it.

I went searching on the freebsd mailing list.and found help from John Russell jr@paranoia.demon.nl who sent me samples/favicon.ico, for which I am grateful.  John claims to have obtained this icon from the Hummingbird/Exceed PC inetd program.

If you want to see what the graphics looks like, this page has two sizes, one is quite small (10KB) and the other is a bit sizey (45KB).

What do I do with it?

Put your favicon.ico in the directory of your choice.  I put mine in the root directory of my website.  You can also use a different icon on different pages if you prefer.  I snatch this from http://www.favicon.com/:
<HEAD>
<LINK REL="SHORTCUT ICON" HREF="http://www.example.org/myicon.ico" type="image/x-icon">
<LINK REL="SHORTCUT"      HREF="http://www.example.org/myicon.ico" type="image/x-icon">
<TITLE>My Title</TITLE>
</HEAD>

What you’ll see now

The next time someone requests your favicon.ico, you’ll be happy in the knowledge that you are spreading the BSD Daemon image around.  And you’ll also see this in your logs:
"GET /favicon.ico HTTP/1.0" 304 -

  2 Responses to “favicon.ico”

  1. (This comment was originally submitted as a standalone article)

    As described in <A HREF="http://www.freebsddiary.org/favicon.php">http://www.freebsddiary.org/favicon.php</A&gt;, sometimes you see these entries in the logfile of your webserver:

    "GET /favicon.ico HTTP/1.1" 404 3711

    They’re from people who bookmark your website (if they’re using Internet Explorer) or if you have the following HTML code in your HTML pages (if they have Mozilla or Konquerer).

    &lt;LINK REL="SHORTCUT ICON" HREF="http://www.mydomain.com/favicon.ico"&gt;

    Making such an icon is easy if you’re using Microsoft Windows (just use PaintBrush and save it as a ICO file) and relative easy if you’re using a Unix-like operating system.
    This part is easy, or not, depending on your graphical skills. There are several tools available for this task. I used GIMP, it’s available from the ports-collection.

    The picture should be 16×16 pixels. Editing something that small can be tricky, but if you zoom in up to 1600% it will be easy to make a nice drawing.

    If you save it, choose PNM format. It can be anything, but PNM will have the least problems for the next step.
    After you’ve made the image, it has to be transformed into the Windows Icon format. The easiest way is to use Netpbm (available as a port in graphics/netpbm). If it was saved as an PNM file, the way to convert it into the Windows Icon format is with:

    ppmtowinicon -output favicon.ico &lt;inputfile.pnm&gt;

    If you had saved it as a different format, you should convert it from that specific format into PPM format first. For example, if it was in the PNG or GIF format:

    giftopnm &lt;inputfile.gif&gt; | ppmtowinicon -output favicon.ico
    pngtopnm &lt;inputfile.png&gt; | ppmtowinicon -output favicon.ico

    There are more options available in Netpbm, like rescaling (pnmscale), cropping (pnmcrop) and rotating (pnmrotate). Very handy if you want to run batch jobs on your pictures, like making thumnails from your digital photos.
    Now the easiest part and the one which shows of all the hard work. Add this line to the HEAD section of your webpage:

    &lt;LINK REL="SHORTCUT ICON" HREF="http://www.mydomain.com/favicon.ico"&gt;

    And reload the page. In Mozilla it shows up in the address-bar. Netscape 4.7 doesn’t support it. Konquerer does ask for them, but I don’t have it so I couldn’t find out where it shows up. Opera 5.0 doesn’t support it. For Galeon I couldn’t find it neither. Internet Explorer 5.0 does support it when you bookmark pages.

    Keep in mind that it is a de-facto standard: there is no documentation about it on the W3C pages. If you want check if your browser supports it, have a look at <A HREF="http://www.mavetju.org/">http://www.mavetju.org/</A&gt;, <A HREF="http://slashdot.org/">http://slashdot.org/</A&gt;, <A HREF="http://sourceforge.net/">http://sourceforge.net/</A&gt; or <A HREF="http://www.theregister.co.uk/">http://www.theregister.co.uk/</A&gt;.