PHP code example of lordelph / icofileloader

1. Go to this page and download the library: Download lordelph/icofileloader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lordelph / icofileloader example snippets


$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');

$im = $loader->extractIcon('/path/to/icon.ico', 32, 32, ['background'=>'#FFFFFF']);

$im = $loader->extractIcon('/path/to/icon.ico', 100, 100);

$im = $loader->extractIcon('https://assets-cdn.github.com/favicon.ico', 16, 16);

$data = file_get_contents('/path/to/icon.ico');
$im = $loader->extractIcon($data, 16, 16);

$icon = $loader->fromFile('/path/to/icon.ico');
foreach ($icon as $idx => $image) {
     $im=$loader->renderImage($image);
     
     $filename=sprintf('img%d-%dx%d.png', $idx, $image->width, $image->height);
     imagepng($im, $filename);
     
     printf("rendered %s as %s\n", $image->getDescription(), $filename);
}