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
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
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
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
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
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
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
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
Returns a list of filters this handler provides.
The list returned is in format:
- array(
- 0 => <string filtername>,
- 1 => <string filtername>,
- ...
- )
hasFilter
Checks if a given filter is available in this handler.
Parameters:
Name | Type | Description |
---|---|---|
$name |
string | Name of the filter to check for. |
load
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
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
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. |