I have WordPress set up to load, parse and cache the favicons for sites added as bookmarks. The PHP class I was using struggled with certain ICO files, such as alistapart.com and sitepoint.com.

In the below example, we load a favicon from the filesystem into memory. For my use-case, the favicon has been loaded directly from the external site. Wanting to avoid unnecessary temporary files, I found that you can pipe data to and from the convert program from ImageMagick using streams in PHP. Assuming that you have determined that the favicon is an ico file;

convert ico:- -thumbnail 16x16 -alpha on -background none -flatten png:-