ezcImageHandler implementation for the GD2 extension of PHP, including filters.
This ezcImageHandler is used when you want to manipulate images using ext/GD in your application.
Note: If you experience problems with loading some JPEG files that work in your image viewer, please set the php.ini directive 'gd.jpeg_ignore_warning' to true (possible via http://www.php.net/ini_set).
Source for this file: /ImageConversion/src/handlers/gd.php
ezcImageMethodcallHandler | --ezcImageGdBaseHandler | --ezcImageGdHandler
Version: | //autogentag// |
public void |
colorspace(
$space
)
Colorspace filter. |
public void |
crop(
$x
, $y
, $width
, $height
)
Crop filter. |
public void |
croppedThumbnail(
$width
, $height
)
Creates a thumbnail, and crops parts of the given image to fit the range best. |
public void |
filledThumbnail(
$width
, $height
, [ $color
= array()] )
Creates a thumbnail, and fills up the image to fit the given range. |
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(
$width
, $height
)
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. |
public void |
watermarkAbsolute(
$image
, $posX
, $posY
, [ $width
= false] , [ $height
= false] )
Watermark filter. |
public void |
watermarkPercent(
$image
, $posX
, $posY
, [ $size
= false] )
Watermark filter. |
From ezcImageGdBaseHandler | |
---|---|
public ezcImageGdBaseHandler |
ezcImageGdBaseHandler::__construct()
Create a new image handler. |
public void |
ezcImageGdBaseHandler::close()
Close the file referenced by $image. |
public static ezcImageHandlerSettings |
ezcImageGdBaseHandler::defaultSettings()
Creates default settings for the handler and returns it. |
public string |
ezcImageGdBaseHandler::load()
Load an image file. |
protected void |
ezcImageGdBaseHandler::replaceTransparency()
Replaces a transparent background with the given color. |
public void |
ezcImageGdBaseHandler::save()
Save an image file. |
Colorspace filter.
Transform the colorspace of the picture. The following colorspaces are supported:
Name | Type | Description |
---|---|---|
$space |
int | Colorspace, one of self::COLORSPACE_* constants. |
Type | 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. |
Method | Description |
---|---|
ezcImageColorspaceFilters::colorspace() |
Colorspace filter. |
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.
Name | Type | Description |
---|---|---|
$x |
int | X offset of the cropping area. |
$y |
int | Y offset of the cropping area. |
$width |
int | Width of cropping area. |
$height |
int | Height of cropping area. |
Type | 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. |
Method | Description |
---|---|
ezcImageGeometryFilters::crop() |
Crop filter. |
Creates a thumbnail, and crops parts of the given image to fit the range best.
This filter creates a thumbnail of the given image. The image is scaled down, keeping the original ratio and keeping the image larger as the given range, if necessary. Overhead for the target range is cropped from both sides equally.
If you are looking for a filter that just resizes your image to thumbnail size, you should consider the ezcImageGdHandler::scale() filter.
Name | Type | Description |
---|---|---|
$width |
int | Width of the thumbnail. |
$height |
int | Height of the thumbnail. |
Method | Description |
---|---|
ezcImageThumbnailFilters::croppedThumbnail() |
Creates a thumbnail, and crops parts of the given image to fit the range best. |
Creates a thumbnail, and fills up the image to fit the given range.
This filter creates a thumbnail of the given image. The image is scaled down, keeping the original ratio and scaling the image smaller as the given range, if necessary. Overhead for the target range is filled with the given color on both sides equally.
The color is defined by the following array format (integer values 0-255):
If you are looking for a filter that just resizes your image to thumbnail size, you should consider the ezcImageGdHandler::scale() filter.
Name | Type | Description |
---|---|---|
$width |
int | Width of the thumbnail. |
$height |
int | Height of the thumbnail. |
$color |
array | Fill color. |
Method | Description |
---|---|
ezcImageThumbnailFilters::filledThumbnail() |
Creates a thumbnail, and fills up the image to fit the given range. |
Common color determination method.
Returns a color identifier for an RGB value. Avoids problems with palette images.
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. |
Type | Description |
---|---|
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
Perform luminance color scale.
Name | Type | Description |
---|---|---|
$scale |
array | Array of RGB values (numeric index). |
Type | Description |
---|---|
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed |
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!
Name | Type | Description |
---|---|---|
$resource |
resource(GD) | The image resource to convert |
$dimensions |
array(string=>int) | X and Y dimensions. |
General scaling method to perform actual scale to new dimensions.
Name | Type | Description |
---|---|---|
$width |
int | Width. |
$height |
int | Height. |
Type | Description |
---|---|
ezcImageFilterFailedException. |
If the operation performed by the the filter failed. |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
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:
Name | Type | Description |
---|---|---|
$width |
int | Scale to width |
$height |
int | Scale to height |
$direction |
int | Scale to which direction. |
Type | 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. |
Method | Description |
---|---|
ezcImageGeometryFilters::scale() |
Scale filter. |
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.
Name | Type | Description |
---|---|---|
$width |
int | Scale to width |
$height |
int | Scale to height |
Type | Description |
---|---|
ezcBaseValueException |
If a submitted parameter was out of range or type. |
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
Method | Description |
---|---|
ezcImageGeometryFilters::scaleExact() |
Scale exact filter. |
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.
Name | Type | Description |
---|---|---|
$height |
int | Scale to height |
$direction |
int | Scale to which direction |
Type | 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. |
Method | Description |
---|---|
ezcImageGeometryFilters::scaleHeight() |
Scale after height filter. |
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.
Name | Type | Description |
---|---|---|
$width |
int | Scale to width |
$height |
int | Scale to height |
Type | 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. |
Method | Description |
---|---|
ezcImageGeometryFilters::scalePercent() |
Scale percent measures filter. |
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.
Name | Type | Description |
---|---|---|
$width |
int | Scale to width |
$direction |
int | Scale to which direction |
Type | 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. |
Method | Description |
---|---|
ezcImageGeometryFilters::scaleWidth() |
Scale after width filter. |
Scale colors by threshold values.
Thresholds are defined by the following array structures:
Name | Type | Description |
---|---|---|
$thresholds |
array |
Type | Description |
---|---|
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
Watermark filter.
Places a watermark on the image. The file to use as the watermark image is given as $image. The $posX, $posY and $size values are given in pixel. The watermark appear at $posX, $posY in the destination image with a size of $size pixel. If $size is ommitted, the watermark image will not be resized.
Name | Type | Description |
---|---|---|
$image |
string | The image file to use as the watermark |
$posX |
int | X position in the destination image in pixel. |
$posY |
int | Y position in the destination image in pixel. |
$width |
int|bool | Pixel size of the watermark, false to keep size. |
$height |
int|bool | Pixel size of the watermark, false to keep size. |
Type | Description |
---|---|
ezcImageInvalidReferenceException |
If no valid resource for the active reference could be found. |
ezcImageFileNotProcessableException |
If the given watermark image could not be loaded. |
ezcImageFilterFailedException |
If the operation performed by the the filter failed. |
ezcBaseValueException |
If a submitted parameter was out of range or type. |
Method | Description |
---|---|
ezcImageWatermarkFilters::watermarkAbsolute() |
Watermark filter. |
Watermark filter.
Places a watermark on the image. The file to use as the watermark image is given as $image. The $posX, $posY and $size values are given in percent, related to the destination image. A $size value of 10 will make the watermark appear in 10% of the destination image size. $posX = $posY = 10 will make the watermark appear in the top left corner of the destination image, 10% of its size away from its borders. If $size is ommitted, the watermark image will not be resized.
Name | Type | Description |
---|---|---|
$image |
string | The image file to use as the watermark |
$posX |
int | X position in the destination image in percent. |
$posY |
int | Y position in the destination image in percent. |
$size |
int|bool | Percentage size of the watermark, false for none. |
Type | 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. |
Method | Description |
---|---|
ezcImageWatermarkFilters::watermarkPercent() |
Watermark filter. |