Create Favicon With Imagick

Create Favicon With Imagick

Here is an example that will take any image format supported by Image Magick (is there one that is not?) and create a 16 pixel favicon image from it. The cropThumbnailImage() method does the work of resizing and cropping in a single swoop while the setFormat() method converts the file to .ico format.

/*** set the image name ***/
$img 'test.jpg';

/*** read the image into imagick ***/
$Imagick = new Imagick($img);

/*** crop and thumbnail the image ***/

/*** set the format to ico ***/

/*** write the favicon.ico file ***/

Exception $e)