Image Toolbox Wrapper

by sintaks
This is a very simple wrapper for the very-excellent Image_Toolbox class.

Image_Toolbox Component


I had a hard time finding a good image-resizing component/helper/whatever for Cake. After searching http://phpclasses.org for a bit, I found http://image-toolbox.sourceforge.net/ (Image_Toolbox)

Installation

Pretty simple. Go to http://image-toolbox.sourceforge.net/ and download the Image_Toolbox.class.php to your vendors directory.

The component code (save as image_toolbox.php in your components directory):

Component Class:

<?php 
class ImageToolboxComponent extends Object {
    public function 
__construct()
    {
        
parent::__construct();    
        
vendor('imagetoolbox/Image_Toolbox.class');
    }
    public function 
makeToolbox()
    {
        
$args func_get_args();
        
$argc func_num_args();
        
$params = array();
        for(
$i 0$i $argc$i++)
        {
            
$params[] = '"'.$args[$i].'"';
        }
                
$pstring implode(","$params);
        
$estring "return new Image_Toolbox($pstring);";
        return eval(
$estring);
    }
}

?>

Usage


Usage is as follows:

Controller Class:

<?php 
//... code
//Stock Toolbox
$box1 $this->ImageToolbox->makeToolbox();

//Pass normal Image_Toolbox constructor params to the makeToolbox
//function:
$box2 $this->ImageToolbox->makeToolbox("path/to/image.jpg");

//...code
?>

Report

More on Components

Advertising

Comments

login to post a comment.