Smokes your problems, coughs fresh air.

png2ico: converting favicons to Windows’ ICO format

Even though, strictly speaking, I should be using favicons in anything but Windows’ ICO format and refer to them from a <link>-tag at any location other than /favicon.ico, I sometimes like to help Microsoft break the web by putting an ICO file at the location that they reserved for it (/favicon.ico).

My tool of choice for converting PNG’s to ICO is Matthias Benkmann’s png2ico. To generate an ICO file with this program, you just need to feed it one or more PNG files. The possibility to include differently sized PNG files can help you make sure that the icon will steal look good when being dragged to the desktop or some other non-miniature context.

$ png2ico
png2ico 2002-12-08  (c) Matthias S. Benkmann
USAGE: png2ico icofile [--colors ] pngfile1 [pngfile2 ...]

Here’s an actual example which creates an ICO file from a single PNG file:

$ file favicon.png 
favicon.png: PNG image data, 16 x 16, 8-bit/color RGBA, non-interlaced
$ png2ico favicon.ico favicon.png 

Of course, we should discourage browsers from doing useless requests for /favicon.ico by actually telling them when it is available: (as if…)

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

Now we can go back to pretending that: No, we’re not encouraging the practice of link squatting. We just happen to have put our favicon in that location.

For the less tech savvy

Update 30 sep 2012: There’s a free online service to convert PNG to ICO: www.pngtoico.com. It doesn’t require you to do anything complicated (like installing Unix stuff). Just pick your original and get the converted image. 🙂

1 Comment

  1. Rowan Rodrik

    Got a mail from Loget X (sent Sep 8):

    Hey Rowan,

    I recently read this article: http://blog.bigsmoke.us/2008/09/04/png2ico. Would it be possible to mention my website (pngtoico.com) and link to it from that within article as a possible alternative to the program?

    That would be greatly appreciated and I’m sure it would help out the less tech-savvy users who stumble onto the article via search engines whilst wondering how to convert between the formats. Thanks.

    Regards,
    Loget X

    And I decided to add a link to his service in the article.

© 2024 BigSmoke

Theme by Anders NorenUp ↑