Apache Zeta Components Manual :: Docs For Class ezcImageTransformation
ImageConversion::ezcImageTransformation
Class ezcImageTransformation
Provides transformations on images using filters and MIME conversions.
Objects of this class group MIME type conversion and filtering of images into transformations of images. Transformations can be chained by referencing to another transformation so that multiple transformations will be produced after each other.
- $filters = array(
- array(
- 'width' => 100
- )
- ),
- array(
- 'x' => 0,
- 'y' => 0,
- 'width' => 100,
- 'height' => 100,
- )
- ),
- );
- $mimeTypes = array( 'image/jpeg', 'image/png' );
- // ezcImageTransformation object returned for further manipulation
- $thumbnail = $converter->createTransformation(
- 'thumbnail',
- $filters,
- $mimeTypes
- );
- 'var/storage/myThumbnail1' ); // res: image/jpeg
- 'var/storage/myThumbnail2' ); // res: image/png
- 'var/storage/myThumbnail3' ); // res: image/.png
- // Animated GIF, will simply be copied!
- 'var/storage/myThumbnail4' ); // res: image/gif
Source for this file: /ImageConversion/src/transformation.php
Version: | //autogentag// |
Member Variables
protected ezcImageConverter |
$converter
The ezcImageConverter |
protected array(ezcImageFilter) |
$filters
Stores the filters utilized by a transformation. |
protected ezcImageHandler |
$lastHandler
The handler last used for filtering. |
protected array(string) |
$mimeOut
Array of MIME types allowed as output for this transformation. Leave empty, for all MIME types to be allowed. |
protected string |
$name
Stores the name of this transformation. |
protected ezcSaveOptions |
$saveOptions
Options for the final save step. |
Method Summary
public ezcImageTransformation |
__construct(
$converter
, $name
, [ $filters
= array()] , [ $mimeOut
= array()] , [ $saveOptions
= null] )
Initialize transformation. |
public void |
addFilter(
$filter
, [ $before
= null] )
Add a filter to the conversion. |
public string |
getOutMime(
$fileIn
, [ $mimeIn
= null] )
Determine output MIME type Returns the MIME type that the transformation will output. |
protected void |
setFilters(
$filters
)
Set the filters for this transformation. |
protected void |
setMimeOut(
$mime
)
Sets the MIME types which are allowed for output. |
public void |
setSaveOptions(
$options
)
Sets the save options. |
public void |
transform(
$fileIn
, $fileOut
)
Apply the given filters for the transformation. |
Methods
__construct
Initialize transformation.
Parameters:
Name | Type | Description |
---|---|---|
$converter |
ezcImageConverter | The global converter. |
$name |
string | Name for the transformation. |
$filters |
array(ezcImageFilter) | Filters to apply. |
$mimeOut |
array(string) | Output MIME types. |
$saveOptions |
ezcImageSaveOptions | Options for saving images. |
Exceptions:
Type | Description |
---|---|
ezcImageMimeTypeUnsupportedException |
If the output type is unsupported. |
ezcImageFiltersException |
On invalid filter or filter settings error. |
addFilter
Add a filter to the conversion.
Adds a filter with the specific settings. Filters can be added either before an existing filter or at the end (leave out $before parameter).
Parameters:
Name | Type | Description |
---|---|---|
$filter |
ezcImageFilter | The filter definition. |
$before |
int | Where to add the filter |
Exceptions:
Type | Description |
---|---|
ezcImageFilterNotAvailableException |
If the given filter is not available. |
getOutMime
Determine output MIME type Returns the MIME type that the transformation will output.
Parameters:
Name | Type | Description |
---|---|---|
$fileIn |
string | File that should deal as input for the transformation. |
$mimeIn |
string | Specify the MIME type, so method does not need to. |
Exceptions:
Type | Description |
---|---|
ezcImageAnalyzerException |
If the input type is unsupported. |
setFilters
Set the filters for this transformation.
Checks if the filters defined are available and saves them to the created transformation if everything is okay.
Parameters:
Name | Type | Description |
---|---|---|
$filters |
array(ezcImageFilter) | Array of filter objects. |
Exceptions:
Type | Description |
---|---|
ezcBaseFileException |
If the filter array contains invalid object entries. |
ezcImageFilterNotAvailableException |
If a filter is not available. |
setMimeOut
Sets the MIME types which are allowed for output.
Parameters:
Name | Type | Description |
---|---|---|
$mime |
array | MIME types to allow output for. |
Exceptions:
Type | Description |
---|---|
ezcImageMimeTypeUnsupportedException |
If the MIME types cannot be used as output of any of the handlers in the converter. |
setSaveOptions
Sets the save options.
Sets the save options, that are used for the final save step of the transformation.
Parameters:
Name | Type | Description |
---|---|---|
$options |
ezcImageSaveOptions | Save options. |
transform
Apply the given filters for the transformation.
Applies the conversion as defined to the given file and saves it as defined.
Parameters:
Name | Type | Description |
---|---|---|
$fileIn |
string | The file to transform. |
$fileOut |
string | The file to save the transformed image to. |
Exceptions:
Type | Description |
---|---|
ezcImageTransformationException |
If an error occurs during the transformation. The returned exception contains the exception the problem resulted from in it's public $parent attribute. |
ezcBaseFileNotFoundException |
If the file you are trying to transform does not exists. |
ezcBaseFilePermissionException |
If the file you are trying to transform is not readable. |