Reputation: 61
I have tried to use php to caculate a image's avarage color.
So I use the php function: imagecolorat()
, imagecreatefromstring()
This is a part of my code:
$fcontents = file_get_contents($imgname);
$im = @imagecreatefromstring($fcontents);
But I find it can read image successfully except .ico How to deal with it?
Upvotes: 0
Views: 1302
Reputation: 301075
Try https://github.com/lordelph/icofileloader
$loader = new Elphin\IcoFileLoader\IcoFileService;
$im = $loader->extractIcon('/path/to/icon.ico', 32, 32);
//$im is a GD image resource, so we could, for example, save this as a PNG
imagepng($im, '/path/to/output.png');
Upvotes: 1
Reputation: 3659
Apparently, it is possible using this class
http://www.phpclasses.org/package/2369-PHP-Extract-graphics-from-ico-files-into-PNG-images.html
Upvotes: 0
Reputation: 4981
Function imagecreatefromstring() does not work with .ico - format: imagecreatefromstring() returns an image identifier representing the image obtained from the given image. These types will be automatically detected if your build of PHP supports them: JPEG, PNG, GIF, WBMP, and GD2.
Upvotes: 0