Image_Tools
[ class tree: Image_Tools ] [ index: Image_Tools ] [ all elements ]

Class: Image_Tools

Source Location: /Image_Tools-0.4.1/Image/Tools.php

Class Overview


This is the Image_Tools base class


Author(s):

Version:

  • Release: 0.4.1

Copyright:

  • Copyright (c) 2003-2006 Tobias Schlitt <toby@php.net>, Firman Wandayandi <firman@php.net>

Variables

Methods


Child classes:

Image_Tools_Border
This class provide border creation on an image.
Image_Tools_Marquee
This class provide marquee extraction tool for manipulating an image.
Image_Tools_Mask
This class provide masking tool for manipulating an image.
Image_Tools_Swap
This class provide masking tool for manipulating an image.
Image_Tools_Thumbnail
This class provide thumbnail creating tool for manipulating an image

Inherited Variables

Inherited Methods


Class Details

[line 198]
This is the Image_Tools base class

Every image-tool has to derive from this class and implement several methods itself. Other methods are implemented in the base class directly, but may only be called on the sub-classes. The only method being called directly from the base class is the factory() method.

  • Version: Release: 0.4.1
  • License: BSD License
  • Copyright: Copyright (c) 2003-2006 Tobias Schlitt <toby@php.net>, Firman Wandayandi <firman@php.net>
  • Author: Tobias Schlitt <toby@php.net>
  • Author: Firman Wandayandi <firman@php.net>


[ Top ]


Class Variables

$apiVersion =  '0.1'

[line 266]

Contains the api-version of the baseclass. The API version has to follow the PEAR version naming standard.
  • Access: protected

Type:   string


[ Top ]

$availableMethods = array()

[line 247]

Has to contain all available methods (as the keys of the array) and the expected parameters (in an array) as the values. The structure of this array is as follows:

$availableMethods = array( 'myMethod' => array( 'foo' => 'int', 'db' => 'DB' 'fooBar' => array( 'baz' => 'resource', 'bun' => 'mixed' ) );

  • Access: protected

Type:   array


[ Top ]

$availableOptions = array()

[line 227]

Has to contain all available options of a subclass. The index of

the array is the option name, the value is either a PHP variable type (e.g. int, string, float, resource,...) or a class name (e.g. Image_Tools, DB,...). Also allowed the are the special values 'number' and 'mixed'. The structure of that array is as follows:

$availableOptions = array( 'foo' => 'int', 'bar' => 'float', 'db' => 'DB', 'img' => 'resource' );

  • Access: protected

Type:   array


[ Top ]

$options = array()

[line 208]

Contain the options inside all subclasses.
  • Access: protected

Type:   array


[ Top ]

$resultImage =  null

[line 274]

Result rendered image.
  • Access: protected

Type:   resource


[ Top ]

$version =  ''

[line 257]

Contains the version of the specific subclass. A version has to follow the PEAR version naming standard, which can be found here: http://pear.php.net/group/docs/20040226-vn.php
  • Access: protected

Type:   string


[ Top ]



Method Detail

Image_Tools (Constructor)   [line 290]

Image_Tools Image_Tools( [array $options = array()])

Constructor

this method has no purpose for Image_Tools, but defines the API for all base classes. Calling this directly with $foo = new Image_Tools(...); will cause an error.


Parameters:

array   $options     optional Options.

[ Top ]

availableMethods   [line 826]

array availableMethods( )

Get available methods

returns an array where the keys are the method names available and the value for each key is an array containing the parameter the specific method expects.


[ Top ]

availableOptions   [line 777]

array availableOptions( )

Get all available options of the subclass

[ Top ]

createImage   [line 578]

resource|PEAR_Error createImage( mixed $input)

Create a GD image resource from given input.

This method tried to detect what the input, if it is a file the createImageFromFile will be called, otherwise createImageFromString().


Parameters:

mixed   $input     The input for creating an image resource. The value may a string of filename, string of image data or GD image resource.

[ Top ]

createImageFromFile   [line 507]

mixed createImageFromFile( string $filename)

Create a GD image resource from file (JPEG, PNG, WBMP and XBM support).
  • Return: GD image resource on success, PEAR_Error on failure.
  • Access: public

Parameters:

string   $filename     The image filename.

[ Top ]

createImageFromString   [line 546]

mixed createImageFromString( string $data)

Create a GD image resource from a string data.
  • Return: GD image resource on success, PEAR_Error on failure.
  • Access: public

Parameters:

string   $data     The string image data.

[ Top ]

display   [line 663]

bool|PEAR_Error display( [int $type = IMAGETYPE_PNG])

Display rendered image (send it to browser).

This method is a common implementation to render and output an image. The method calls the render() method automatically and outputs the image to the browser.


Parameters:

int   $type     optional Type of format image (use defined image type constants), default is IMAGETYPE_PNG.

[ Top ]

factory   [line 323]

object New &factory( string $tool, [array $options = array()])

Create a new instance of an image tool

This method will create a new image tool, defined by the $tool var, which is a string it will call the constructor of the specific tool and return it (if no error occurs)


Parameters:

string   $tool     Tool name
array   $options     optional Options

[ Top ]

get   [line 478]

mixed|PEAR_Error get( string $option)

Get the value of the option

returns the value of an option of, an error if the option is not available.


Parameters:

string   $option     Option name.

[ Top ]

getAPIVersion   [line 848]

string getAPIVersion( )

Get the API version of the common base

This methods can be called statically using Image_Tools::getAPIVersion() or from the subclass e.g Image_Tools_Border::getAPIVersion() or $border->getAPIVersion()

  • Return: Image_Tools base class api-version
  • Access: protected

[ Top ]

getResultImage   [line 641]

resource getResultImage( )

Get rendered image.
  • Return: The GD image resource of rendered result.
  • Access: public

[ Top ]

getVersion   [line 867]

string getVersion( )

Get the subclass version.
  • Return: Version.
  • Access: protected

[ Top ]

isGDImageResource   [line 602]

bool isGDImageResource( mixed $value)

Find the whether a value is the GD image resource or not.
  • Return: TRUE if a value is the GD image resource, otherwise FALSE.
  • Access: public

Parameters:

mixed   $value     Value to evaluate.

[ Top ]

isValidOption   [line 420]

bool|PEAR_Error isValidOption( $name, mixed $value, mixed $option)

Has the option a valid value? Determines, if the value given is valid for the option.

Parameters:

mixed   $option     A single option name
mixed   $value     Option value
   $name     

[ Top ]

render   [line 624]

void render( )

Render the result of a tool to the given image

Since that's the purpose of all image tools, this method should stay with it's api as is. The rendering itself must be tool specific. The method gets a GD2 image as it's parameter. The creation of images inside Image_Tools is not supported.


Overridden in child classes as:

Image_Tools_Border::render()
This method is useless, use directly call for specific border style method.
Image_Tools_Marquee::render()
Draw extraction result to resource.
Image_Tools_Swap::render()
Apply swap color to image and output result.
Image_Tools_Thumbnail::render()
Draw thumbnail result to resource.

[ Top ]

save   [line 711]

bool|PEAR_Error save( string $path, [int $type = IMAGETYPE_PNG])

Save rendered image to a file.

Parameters:

string   $path     Path to destination filename.
int   $type     optional Type of image format (use defined image type constants), default is IMAGETYPE_PNG.

[ Top ]

set   [line 382]

bool|PEAR_Error set( mixed $option, [mixed $value = null])

Set the option(s)

Set a single or multiple options. The parameter of that method may either be a single options array or a key/value pair setting a single option. This method has not to be reimplemented by the Image_Tools sub classes.


Parameters:

mixed   $option     A single option name or the options array
mixed   $value     Option value if $option is string

[ Top ]

supportsMethod   [line 799]

array|bool supportsMethod( string $methodName)

Get the method parameters

Parameters:

string   $methodName     Method name.

[ Top ]

supportsOption   [line 754]

bool supportsOption( string $option)

Find out the whether a subclass supports the option

Parameters:

string   $option     Option name.

[ Top ]


Documentation generated on Thu, 23 Nov 2006 18:00:10 -0500 by phpDocumentor 1.3.0. PEAR Logo Copyright © PHP Group 2004.