PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, October 9, 2022

[FIXED] How can I create a favicon locally with a script?

 October 09, 2022     favicon, gd, imagemagick, php     No comments   

Issue

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?


Solution

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



Answered By - Sean Dawson
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing