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

Class: Image_Tools

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

Class Overview


This is the Image_Tools base class


Author(s):

Version:

  • Release: 0.4.2

Copyright:

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

Variables

Methods


Child classes:

Image_Tools_Mask
This class provide masking tool for manipulating an image.
Image_Tools_Border
This class provide border creation on an image.
Image_Tools_Swap
This class provide masking tool for manipulating an image.
Image_Tools_Marquee
This class provide marquee extraction 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 201]
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: 0.4.2
  • Copyright: Copyright (c) 2003-2006 Tobias Schlitt <toby@php.net>, Firman Wandayandi <firman@php.net>
  • License: BSD License


[ Top ]


Class Variables

$apiVersion =  '0.2.1'

[line 269]

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

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

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

Contain the options inside all subclasses.
  • Access: protected

Type:   array


[ Top ]

$resultImage =  null

[line 277]

Result rendered image.
  • Access: protected

Type:   resource


[ Top ]

$version =  ''

[line 260]

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

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

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

array availableOptions( )

Get all available options of the subclass

[ Top ]

createImage   [line 581]

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

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

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

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

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

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

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

resource getResultImage( )

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

[ Top ]

getVersion   [line 870]

string getVersion( )

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

[ Top ]

isGDImageResource   [line 605]

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

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

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_Swap::render()
Apply swap color to image and output result.
Image_Tools_Marquee::render()
Draw extraction result to resource.
Image_Tools_Thumbnail::render()
Draw thumbnail result to resource.

[ Top ]

save   [line 714]

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

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

array|bool supportsMethod( string $methodName)

Get the method parameters

Parameters:

string   $methodName   —  Method name.

[ Top ]

supportsOption   [line 757]

bool supportsOption( string $option)

Find out the whether a subclass supports the option

Parameters:

string   $option   —  Option name.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:49:14 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.