FOSS Unleashed

How to generate an .ico file with plan9-port

Provided a 32x32 pixel png named test.png, we can produce a favicon.ico file with plan9-port.

9 png < test.png | 9 toico > favicon.ico

A gentle reminder that 9 is simply a script that wraps the plan9-port commands so that they do not pollute your normal $PATH. So the programs called are actually png and toico. The png program simply takes a .png through stdin, and outputs a plan9 image file to stdout. Then the toico program takes a plan9 image file from stdin, and outputs a .ico file to stdout.

However, that’s not how I produced my favicon.ico file. Instead, from plan9-port’s paint, I created a completely black image, and named it test.img. From there I ran the following:

9 crop -r 0 0 32 32 < test.img | 9 toico > favicon.ico

This has some similarities to the previous, but instead of converting to a plan9 image, we crop it with the crop program, pulling out a 32x32 square from the top left corner of the image. Since crop takes in a plan9 image, and outputs a plan9 image, we can just run toico as before.