Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Favicon to PNG in PHP

Tags:

php

favicon

png

I need a PHP script to convert favicons to PNGs while keeping their original dimensions.

I know Google has it's secret icon converter - http://www.google.com/s2/favicons?domain=http://facebook.com/ but this converts favicons to 16x16 even if they they were originally larger. So basically I need this, minus the shrinking effect.

I've also seen this - http://www.controlstyle.com/articles/programming/text/php-favicon/ but I couldn't get it to work after hours of messing around with it.

Basically I am trying to automatically grab the icon for a link that will be as large as possible - automatically 48x48 png based on a URL would be the perfect scenario, but I don't know of any humanly possible way to do this given that no websites happen to keep a 48x48 icon in a publicly accessible spot.

Does anybody know of a script/service or have a suggestion? Thanks!

like image 498
cjroth Avatar asked Jan 03 '11 13:01

cjroth


1 Answers

So I ended up using a class called FloIcon that could convert BMPs to ICO. I should note that it's always important to check the file type of an icon and not assume that .ico means bmp because some sites (like Facebook) were actually PNG).

@goker.cebeci Your service looks awesome! The main thing is that I needed my icons to be the maximum size when possible, so I just wrote my own script.

like image 182
cjroth Avatar answered Sep 17 '22 23:09

cjroth