ImageConversion: ezcImageGdHandler
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcImageGdHandler
|
ezcImageHandler implementation for the GD2 extension of PHP, including filters. [
source]
Implemented Interfaces
This ezcImageHandler is used when you want to manipulate images using ext/GD in your application.
Parents
ezcImageMethodcallHandler
|
--ezcImageGdBaseHandler
|
--ezcImageGdHandler
Method Summary
|
public void |
colorspace(
$space )
Colorspace filter. |
|
public void |
crop(
$x, $y, $width, $height )
Crop filter. |
|
protected int |
getColor(
$resource, $r, $g, $b )
Common color determination method. |
|
protected void |
luminanceColorScale(
$scale )
Perform luminance color scale. |
|
protected resource(GD) |
paletteToTruecolor(
$resource, $dimensions )
Convert a palette based image resource to a true color one. |
|
protected void |
performScale(
$dimensions )
General scaling method to perform actual scale to new dimensions. |
|
public void |
scale(
$width, $height, [$direction = ezcImageGeometryFilters::SCALE_BOTH] )
Scale filter. |
|
public void |
scaleExact(
$width, $height )
Scale exact filter. |
|
public void |
scaleHeight(
$height, $direction )
Scale after height filter. |
|
public void |
scalePercent(
$width, $height )
Scale percent measures filter. |
|
public void |
scaleWidth(
$width, $direction )
Scale after width filter. |
|
protected void |
thresholdColorScale(
$thresholds )
Scale colors by threshold values. |
Inherited Methods
From
ezcImageGdBaseHandler :
Methods
colorspace
void colorspace(
int
$space )
Colorspace filter.
Transform the colorspace of the picture. The following colorspaces are supported:
- self::COLORSPACE_GREY - 255 grey colors
- self::COLORSPACE_SEPIA - Sepia colors
- self::COLORSPACE_MONOCHROME - 2 colors black and white
ATTENTION: Using this filter method directly results in the filter being applied to the image which is internally marked as "active" (most commonly this is the last recently loaded one). It is highly recommended to apply filters through the ezcImageGdHandler::applyFilter() method, which enables you to specify the image a filter is applied to.
Parameters
| Name |
Type |
Description |
$space |
int |
Colorspace, one of self::COLORSPACE_* constants. |
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcBaseValueException |
If the parameter submitted as the colorspace was not within the self::COLORSPACE_* constants. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
crop
void crop(
int
$x, int
$y, int
$width, int
$height )
Crop filter.
Crop an image to a given size. This takes cartesian coordinates of a rect area to crop from the image. The cropped area will replace the old image resource (not the input image immediately, if you use the
ezcImageConverter). Coordinates are given as integer values and are measured from the top left corner.
ATTENTION: Using this filter method directly results in the filter being applied to the image which is internally marked as "active" (most commonly this is the last recently loaded one). It is highly recommended to apply filters through the ezcImageGdHandler::applyFilter() method, which enables you to specify the image a filter is applied to.
Parameters
| Name |
Type |
Description |
$x |
int |
Start cropping, x coordinate. |
$y |
int |
Start cropping, y coordinate. |
$width |
int |
Width of cropping area. |
$height |
int |
Height of cropping area. |
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
ezcBaseValueException |
If a submitted parameter was out of range or type. |
getColor
int getColor(
reource(GD)
$resource, int
$r, int
$g, int
$b )
Common color determination method.
Returns a color identifier for an RGB value. Avoids problems with palette images.
Parameters
| Name |
Type |
Description |
$resource |
reource(GD) |
The image resource to get a color for. |
$r |
int |
Red value. |
$g |
int |
Green value. |
$b |
int |
Blue value. |
Throws
| Class | Description |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
luminanceColorScale
void luminanceColorScale(
array
$scale )
Perform luminance color scale.
Parameters
| Name |
Type |
Description |
$scale |
array |
Array of RGB values (numeric index). |
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed |
paletteToTruecolor
resource(GD) paletteToTruecolor(
resource(GD)
$resource,
$dimensions )
Convert a palette based image resource to a true color one.
Takes a GD resource that does not represent a true color image and converts it to a true color based resource. Do not forget, to replace the actual resource in the handler, if you use this ,method!
Parameters
| Name |
Type |
Description |
$resource |
resource(GD) |
The image resource to convert |
$dimensions |
|
|
performScale
void performScale(
array
$dimensions )
General scaling method to perform actual scale to new dimensions.
Parameters
| Name |
Type |
Description |
$dimensions |
array |
Dimensions as array('x' => <int>, 'y' => <int>). |
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException. |
If the operation performed by the the filter failed. |
scale
void scale(
int
$width, int
$height, [int
$direction = ezcImageGeometryFilters::SCALE_BOTH] )
Scale filter.
General scale filter. Scales the image to fit into a given box size, determined by a given width and height value, measured in pixel. This method maintains the aspect ratio of the given image. Depending on the given direction value, this method performs the following scales:
- ezcImageGeometryFilters::SCALE_BOTH:
The image will be scaled to fit exactly into the given box
dimensions, no matter if it was smaller or larger as the box
before.
- ezcImageGeometryFilters::SCALE_DOWN:
The image will be scaled to fit exactly into the given box
only if it was larger than the given box dimensions before. If it
is smaller, the image will not be scaled at all.
- ezcImageGeometryFilters::SCALE_UP:
The image will be scaled to fit exactly into the given box
only if it was smaller than the given box dimensions before. If it
is larger, the image will not be scaled at all. ATTENTION:
In this case, the image does not necessarily fit into the given box
afterwards.
ATTENTION: Using this filter method directly results in the filter being applied to the image which is internally marked as "active" (most commonly this is the last recently loaded one). It is highly recommended to apply filters through the ezcImageGdHandler::applyFilter() method, which enables you to specify the image a filter is applied to.
Parameters
| Name |
Type |
Description |
$width |
int |
Scale to width |
$height |
int |
Scale to height |
$direction |
int |
Scale to which direction. |
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
ezcBaseValueException |
If a submitted parameter was out of range or type. |
scaleExact
void scaleExact(
int
$width, int
$height )
Scale exact filter.
Scale the image to a fixed given pixel size, no matter to which direction.
ATTENTION: Using this filter method directly results in the filter being applied to the image which is internally marked as "active" (most commonly this is the last recently loaded one). It is highly recommended to apply filters through the ezcImageGdHandler::applyFilter() method, which enables you to specify the image a filter is applied to.
Parameters
| Name |
Type |
Description |
$width |
int |
Scale to width |
$height |
int |
Scale to height |
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcBaseValueException |
If a submitted parameter was out of range or type. |
scaleHeight
void scaleHeight(
int
$height, int
$direction )
Scale after height filter.
Scales the image to a give height, measured in pixel. Scales the width automatically while keeping the ratio. The direction dictates, if an image may only be scaled self::SCALE_UP, self::SCALE_DOWN or if the scale may work in self::SCALE_BOTH directions.
ATTENTION: Using this filter method directly results in the filter being applied to the image which is internally marked as "active" (most commonly this is the last recently loaded one). It is highly recommended to apply filters through the ezcImageGdHandler::applyFilter() method, which enables you to specify the image a filter is applied to.
Parameters
| Name |
Type |
Description |
$height |
int |
Scale to height |
$direction |
int |
Scale to which direction |
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
ezcBaseValueException |
If a submitted parameter was out of range or type. |
scalePercent
void scalePercent(
int
$width, int
$height )
Scale percent measures filter.
Scale an image to a given percentage value size.
ATTENTION: Using this filter method directly results in the filter being applied to the image which is internally marked as "active" (most commonly this is the last recently loaded one). It is highly recommended to apply filters through the ezcImageGdHandler::applyFilter() method, which enables you to specify the image a filter is applied to.
Parameters
| Name |
Type |
Description |
$width |
int |
Scale to width |
$height |
int |
Scale to height |
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
ezcBaseValueException |
If a submitted parameter was out of range or type. |
scaleWidth
void scaleWidth(
int
$width, int
$direction )
Scale after width filter.
Scales the image to a give width, measured in pixel. Scales the height automatically while keeping the ratio. The direction dictates, if an image may only be scaled self::SCALE_UP, self::SCALE_DOWN or if the scale may work in self::SCALE_BOTH directions.
ATTENTION: Using this filter method directly results in the filter being applied to the image which is internally marked as "active" (most commonly this is the last recently loaded one). It is highly recommended to apply filters through the ezcImageGdHandler::applyFilter() method, which enables you to specify the image a filter is applied to.
Parameters
| Name |
Type |
Description |
$width |
int |
Scale to width |
$direction |
int |
Scale to which direction |
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
ezcBaseValueException |
If a submitted parameter was out of range or type. |
thresholdColorScale
void thresholdColorScale(
array
$thresholds )
Scale colors by threshold values.
Thresholds are defined by the following array structures:
1. array(
2. <int threshold value> => array(
3. 0 => <int red value>,
4. 1 => <int green value>,
5. 2 => <int blue value>,
6. ),
7. )
Parameters
| Name |
Type |
Description |
$thresholds |
array |
|
Throws
| Class | Description |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
Last updated: Wed, 28 Nov 2007