diff --git a/README.md b/README.md index da0be75..52f7d83 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,17 @@ $ico_lib->save_ico( $destination ); It takes a source file named `example.gif` and produce an output ICO file named `example.ico`. `example.ico` will contain a single image that is the same size as the source image. +You can also render the gif directly on the browser without saving it on the server: + +```php +require( dirname( __FILE__ ) . '/class-php-ico.php' ); + +$source = dirname( __FILE__ ) . '/example.gif'; + +$ico_lib = new PHP_ICO( $source ); +$ico_lib->render_ico(); +```` + The ICO file format is capable of holding multiple images, each of a different size. The PHP ICO library opens up this feature of the ICO format as shown in the following example: ```php diff --git a/class-php-ico.php b/class-php-ico.php index 2e9983e..edfd67f 100644 --- a/class-php-ico.php +++ b/class-php-ico.php @@ -136,6 +136,24 @@ function save_ico( $file ) { return true; } + /** + * Display the ICO file data. + * + * @return boolean true on success and false on failure. + */ + function render_ico() { + if ( ! $this->_has_requirements ) + return false; + + if ( false === ( $data = $this->_get_ico_data() ) ) + return false; + + header('Content-Type: image/x-icon'); + echo $data; + + return true; + } + /** * Generate the final ICO data by creating a file header and adding the image data. *