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

Class: Image_Tools

Source Location: /Image_Tools-1.0.0RC1/Image/Tools.php

Class Overview


This is the Image_Tools base class


Author(s):

Version:

  • Release: 1.0.0RC1

Copyright:

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

Variables

Methods


Child classes:

Image_Tools_Blend
Class provide image blending functions.
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 swap tool for manipulating an image.
Image_Tools_Thumbnail
This class provide thumbnail creating tool for manipulating an image
Image_Tools_Watermark
This class provide a tool to add a little logo on an image

Inherited Variables

Inherited Methods


Class Details

[line 191]
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.

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


[ Top ]


Class Variables

$apiVersion =  '1.0'

[line 259]

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 240]

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 220]

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 201]

Contain the options inside all subclasses.
  • Access: protected

Type:   array


[ Top ]

$resultImage =  null

[line 267]

Result rendered image.
  • Access: protected

Type:   resource


[ Top ]

$version =  ''

[line 250]

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 283]

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 930]

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 881]

array availableOptions( )

Get all available options of the subclass

[ Top ]

createImage   [line 575]

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 501]

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 543]

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 751]

bool|PEAR_Error display( [int $type = IMAGETYPE_PNG], [boolean $force = false])

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.
boolean   $force     Force render or not, whether the image should be re-render or leave the one if its already rendered

[ Top ]

factory   [line 316]

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 472]

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 952]

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 721]

resource getResultImage( [boolean $force = false])

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

Parameters:

boolean   $force     Force render or not, whether the image should be re-render or leave the one if its already rendered

[ Top ]

getVersion   [line 971]

string getVersion( )

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

[ Top ]

isGDImageResource   [line 599]

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 413]

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 ]

postRender   [line 640]

true|PEAR_Error postRender( )

Function which called after render.

Use this method to place any routine after calling render(). This method is optional to extended and return TRUE as default.


Overridden in child classes as:

Image_Tools_Thumbnail::postRender()
Function which called after render.

[ Top ]

preRender   [line 621]

true|PEAR_Error preRender( )

Function which called before render.

Use this method to place any routine before calling render(). This method is optional to extended and returns TRUE as default.


Overridden in child classes as:

Image_Tools_Blend::preRender()
Function which called before render.
Image_Tools_Border::preRender()
Function which called before render.
Image_Tools_Marquee::preRender()
Function which called before render.
Image_Tools_Mask::preRender()
Function which called before render.
Image_Tools_Swap::preRender()
Function which called before render.
Image_Tools_Thumbnail::preRender()
Function which called before render.
Image_Tools_Watermark::preRender()
Function which called before render.

[ Top ]

render   [line 658]

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_Blend::render()
Apply the blend mode.
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.
Image_Tools_Watermark::render()
Draw image with logo result to resource.

[ Top ]

save   [line 808]

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

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.
boolean   $force     Force render or not, whether the image should be re-render or leave the one if its already rendered

[ Top ]

set   [line 375]

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 903]

array|bool supportsMethod( string $methodName)

Get the method parameters

Parameters:

string   $methodName     Method name.

[ Top ]

supportsOption   [line 858]

bool supportsOption( string $option)

Find out the whether a subclass supports the option

Parameters:

string   $option     Option name.

[ Top ]


Documentation generated on Mon, 26 May 2008 06:30:15 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.