I've been using http://tools.dynamicdrive.com/favicon/ for years now for generating favicons. I started using it before I even knew how to do any coding (I'm not great now). I don't mind using the utility because the icons always look pretty good, but I'd love to be able to do it locally.
How can I create a favicon locally with a script? Somehow with PHP, imagemagick / gd or maybe sips from the command line?
You could use imagemagik convert. I took these commands from this website.
First make a master image:
convert some_image.bmp -resize 256x256 -transparent white favicon-256.png
Then we'll want to make images for each size you want to include in the .ico file.
convert favicon-256.png -resize 16x16 favicon-16.png
convert favicon-256.png -resize 32x32 favicon-32.png
convert favicon-256.png -resize 64x64 favicon-64.png
convert favicon-256.png -resize 128x128 favicon-128.png
Now you'll want to bundle them up into the .ico file, the trick I found is to make it 256 colors or it will not display properly!
convert favicon-16.png favicon-32.png favicon-64.png favicon-128.png favicon-256.png -colors 256 favicon.ico
ImageMagick or phpThumb will do this for you but a simpler solution (requiring only PHP and the the GD library) is https://github.com/chrisbliss18/php-ico
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With