/Icons

Load Windows icon files in PHP

Primary LanguagePHPApache License 2.0Apache-2.0

Icons

Load Windows icon files in PHP.

NOTE: 24-bit and 1-bit images are being developed. This library is NOT production-ready

Requirements

  • PHP 5.3.0 or later
  • GD

If you are able to install Imagick on your server, you can stop reading and use that natively instead.

This library is for those of us that have to stick with GD (which includes every PHP developer using Google App Engine).

Usage

<?php
//  Load the library
    include_once('./icon.php');
	
//  Load icon file
    $icon = \Codefocus\Icons\Icon::createFromFile('test.ico');
    
//  Extract the "best" icon that matches your specifications
    $image = $icon->getImage(
        16,  //  minimum width
        4,   //  minimum bitcount
        64,  //  maximum width
        32   //  maximum bitcount
    );
    
//  Render as PNG
    $pngData = $image->renderPng();
    header('Content-type: image/png');
    echo $pngData;