ImageConversion: ezcImageHandler
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcImageHandler
|
Driver interface to access different image manipulation backends of PHP. [
source]
This interface has to be implemented by a handler class in order to be used with the ImageConversion package.
Member Variables
Method Summary
|
public ezcImageHandler |
__construct(
$settings, $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
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
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. |
Throws
| Class | Description |
ezcImageFilterNotAvailableException |
If the desired filter does not exist. |
ezcImageMissingFilterParameterException |
If a parameter for the filter is missing. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
ezcBaseValueException |
If a parameter was not within the expected range. |
See also:
ezcImageHandler::save(),
ezcImageHandler::load().
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. |
Throws
| Class | 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. |
See also:
ezcImageHandler::save(),
ezcImageHandler::load().
convert
void convert(
string
$image, string
$mime )
Converts an image to another MIME type.
Parameters
| Name |
Type |
Description |
$image |
string |
Image reference to convert. |
$mime |
string |
MIME type to convert to. |
Throws
| Class | Description |
ezcImageMimeTypeUnsupportedException |
If the given MIME type is not supported by the filter. |
See also:
ezcImageHandler::save(),
ezcImageHandler::load().
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. |
See also:
ezcImageHandler::close(),
ezcImageHandler::load().
Last updated: Tue, 27 May 2008