php-ico
php-ico copied to clipboard
ability to get the image resource for use with GD
this looks like a nice, lightweight ICO loader. the problem I was hoping to solve is to be able to load a favicon from the web and put it into a GD image resource and then perform some filters or other operations on it. it looks like this ability is missing and only saving to a file is available. perhaps someone familiar with the code can add a method to expose this.
I agree.
Here's my work around, so far. Hope it might help for somebody.
<?php
require_once('php_ico.php');
// Create 16x16 px white image with 127 transparency as a sample
$res_image = imagecreatetruecolor(16, 16);
imagealphablending($res_image, false);
$color_bg = imagecolorallocatealpha($res_image,255,255,255,127);
imagefilledrectangle($res_image,0,0,16,16,$color_bg);
imagefill($res_image, 0, 0, $color_bg);
imagealphablending($res_image,true);
// Convert image to ICO format and get the result
$ico_lib = new PHP_ICO();
$ico_lib->_add_image_data($res_image);
$bin_ico = $ico_lib->_get_ico_data();