## Apache Zeta Components Manual :: Docs For Class ezcImageHandler

### ImageConversion::ezcImageHandler

### Class ezcImageHandler

Driver interface to access different image manipulation backends of PHP.

This interface has to be implemented by a handler class in order to be used with the ImageConversion package.

Source for this file: /ImageConversion/src/interfaces/handler.php

Version: | //autogentag//

### Member Variables

protected array(string=>mixed) | `$properties` Container to hold the properties
protected ezcImageHandlerSettings | `$settings` Settings of the handlers

### Method Summary

public ezcImageHandler | `__construct( $settings )` Create a new image handler.
public abstract bool | `allowsInput( $mime )` Check wether a specific MIME type is allowed as input for this handler.
public abstract bool | `allowsOutput( $mime )` Checks wether a specific MIME type is allowed as output for this handler.
public abstract void | `applyFilter( $image , $filter )` Applies a filter to a given image.
protected void | `checkFileName( $file )` Checks a file name for illegal characters.
public abstract void | `close( $reference )` Close the file referenced by $image.
public abstract void | `convert( $image , $mime )` Converts an image to another MIME type.
public abstract array(string) | `getFilterNames( )` Returns a list of filters this handler provides.
public abstract bool | `hasFilter( $name )` Checks if a given filter is available in this handler.
public abstract string | `load( $file , [ $mime = null] )` Load an image file.
protected bool | `needsTransparencyConversion( $inMime , $outMime )` Returns if a MIME conversion needs transparent color replacement.
public abstract void | `save( $image , [ $newFile = null] , [ $mime = null] , [ $options = null] )` Save an image file.

### Methods

#### __construct

ezcImageHandler __construct( ezcImageHandlerSettings $settings )

Create a new image handler.

Creates an image handler. This should never be done directly, but only through the manager for configuration reasons. One can get a direct reference through manager afterwards. When overwriting the constructor.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$settings` | ezcImageHandlerSettings | Settings for the handler.

#### allowsInput

bool allowsInput( string $mime )

Check wether a specific MIME type is allowed as input for this handler.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$mime` | string | MIME type to check if it's allowed.

#### allowsOutput

bool allowsOutput( string $mime )

Checks wether a specific MIME type is allowed as output for this handler.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$mime` | string | MIME type to check if it's allowed.

#### applyFilter

void applyFilter( string $image , ezcImageFilter $filter )

Applies a filter to a given image.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$image` | string | Image reference to apply the filter on.
`$filter` | ezcImageFilter | Contains which filter operation to apply.

##### Exceptions:

Type | Description
--- | ---
`ezcImageFilterNotAvailableException` | If the desired filter does not exist.
`ezcImageFilterFailedException` | If the operation performed by the the filter failed.
`ezcImageMissingFilterParameterException` | If a parameter for the filter is missing.
`ezcBaseValueException` | If a parameter was not within the expected range.

#### checkFileName

void checkFileName( string $file )

Checks a file name for illegal characters.

Checks if a file name contains illegal characters, which are ", ' and $.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$file` | string | The file name to check.

##### Exceptions:

Type | Description
--- | ---
`ezcImageFileNameInvalidException` | If an invalid character (", ', $) is found in the file name.

#### close

void close( string $reference )

Close the file referenced by $image.

Frees the image reference. You should call close() before.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$reference` | string | The image reference.

#### convert

void convert( string $image , string $mime )

Converts an image to another MIME type.

Use ezcImageHandler::allowsOutput() to determine, if the output MIME type is supported by this handler!

##### Parameters:

Name | Type | Description
--- | --- | ---
`$image` | string | Image reference to convert.
`$mime` | string | MIME type to convert to.

##### Exceptions:

Type | Description
--- | ---
`ezcImageMimeTypeUnsupportedException` | If the given MIME type is not supported by the filter.

#### getFilterNames

array(string) getFilterNames( )

Returns a list of filters this handler provides.

The list returned is in format:

1. array(
2. 0=> <string filtername>,
3. 1=> <string filtername>,
4. ...
5. )

#### hasFilter

bool hasFilter( string $name )

Checks if a given filter is available in this handler.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$name` | string | Name of the filter to check for.

#### load

string load( string $file , [string $mime = null] )

Load an image file.

Loads an image file and returns a reference to it.

For developers: The use of ezcImageHandler::loadCommon() is highly recommended for the implementation of this method!

##### Parameters:

Name | Type | Description
--- | --- | ---
`$file` | string | File to load.
`$mime` | string | The MIME type of the file.

#### needsTransparencyConversion

bool needsTransparencyConversion( string $inMime , string $outMime )

Returns if a MIME conversion needs transparent color replacement.

In case a transparency supporting MIME type (like image/png) is converted to one that does not support transparency, special steps need to be performed. This method returns if the given conversion from $inMime to $outMime is affected by this.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$inMime` | string |
`$outMime` | string |

#### save

void save( string $image , [string $newFile = null] , [string $mime = null] , [ezcImageSaveOptions $options = null] )

Save an image file.

Saves a given open file. Can optionally save to a new file name. The image reference is not freed automatically, so you need to call the close() method explicitly to free the referenced data.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$image` | string | File reference created through.
`$newFile` | string | Filename to save the image to.
`$mime` | string | New MIME type, if differs from initial one.
`$options` | ezcImageSaveOptions | Options for saving.

Documentation generated by phpDocumentor 1.4.3