Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcImageImagemagickHandler

ImageConversion::ezcImageImagemagickHandler

Class ezcImageImagemagickHandler

ezcImageHandler implementation for ImageMagick.

Source for this file: /ImageConversion/src/handlers/imagemagick.php

Implements interfaces:

ezcImageMethodcallHandler
   |
   --ezcImageImagemagickBaseHandler
      |
      --ezcImageImagemagickHandler
Version:   //autogentag//

Method Summary

public void border( $width , $color )
Border filter.
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 string getDirectionModifier( $direction )
Returns the ImageMagick direction modifier for a direction constant.
public void noise( $value )
Noise filter.
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.
public void swirl( $value )
Swirl filter.
public void watermarkAbsolute( $image , $posX , $posY , [ $width = false] , [ $height = false] )
Watermark filter.
public void watermarkPercent( $image , $posX , $posY , [ $size = false] )
Watermark filter.

Inherited Methods

From ezcImageImagemagickBaseHandler
public ezcImageImagemagickBaseHandler ezcImageImagemagickBaseHandler::__construct()
Create a new image handler.
protected void ezcImageImagemagickBaseHandler::addCompositeImage()
Add an image to composite with the given reference.
protected void ezcImageImagemagickBaseHandler::addFilterOption()
Add a filter option to a given reference
public void ezcImageImagemagickBaseHandler::close()
Close the file referenced by $image.
protected void ezcImageImagemagickBaseHandler::colorArrayToString()
Returns a string representation of the given color array.
public static ezcImageHandlerSettings ezcImageImagemagickBaseHandler::defaultSettings()
Creates default settings for the handler and returns it.
public string ezcImageImagemagickBaseHandler::load()
Load an image file.
public void ezcImageImagemagickBaseHandler::save()
Save an image file.

Methods

border

void border( int $width , $color )

Border filter.

Adds a border to the image. The width is measured in pixel. The color is defined in an array of hex values:

  1.  array(
  2.       0 => <red value>,
  3.       1 => <green value>,
  4.       2 => <blue value>,
  5.  );

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 ezcImageImagemagickHandler::applyFilter() method, which enables you to specify the image a filter is applied to.

Parameters:
Name Type Description
$width int Width of the border.
$color array(int) Color.
Exceptions:
Type Description
ezcBaseValueException If a submitted parameter was out of range or type.
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference.
Implementation of:
Method Description
ezcImageEffectFilters::border() Border filter.

colorspace

void colorspace( int $space )

Colorspace filter.

Transform the color space of the picture. The following color space 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 ezcImageImagemagickHandler::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.
Exceptions:
Type Description
ezcBaseValueException If the parameter submitted as the colorspace was not within the self::COLORSPACE_* constants.
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference
Implementation of:
Method Description
ezcImageColorspaceFilters::colorspace() Colorspace filter.

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 ezcImageImagemagickHandler::applyFilter() method, which enables you to specify the image a filter is applied to.

Parameters:
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.
Exceptions:
Type Description
ezcBaseValueException If a submitted parameter was out of range or type.
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference.
Implementation of:
Method Description
ezcImageGeometryFilters::crop() Crop filter.

croppedThumbnail

void croppedThumbnail( int $width , int $height )

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 ezcImageImagemagickHandler::scale() filter.

Parameters:
Name Type Description
$width int Width of the thumbnail.
$height int Height of the thumbnail.
Implementation of:
Method Description
ezcImageThumbnailFilters::croppedThumbnail() Creates a thumbnail, and crops parts of the given image to fit the range best.

filledThumbnail

void filledThumbnail( int $width , int $height , [array $color = array()] )

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):

  1.  array(
  2.       0 => <red value>,
  3.       1 => <green value>,
  4.       2 => <blue value>,
  5.  );

If you are looking for a filter that just resizes your image to thumbnail size, you should consider the ezcImageImagemagickHandler::scale() filter.

Parameters:
Name Type Description
$width int Width of the thumbnail.
$height int Height of the thumbnail.
$color array Fill color.
Implementation of:
Method Description
ezcImageThumbnailFilters::filledThumbnail() Creates a thumbnail, and fills up the image to fit the given range.

getDirectionModifier

string getDirectionModifier( int $direction )

Returns the ImageMagick direction modifier for a direction constant.

ImageMagick supports the following modifiers to determine if an image should be scaled up only, down only or in both directions:

  1.   SCALE_UP:   >
  2.   SCALE_DOWN: <

This method returns the correct modifier for the internal direction constants.

Parameters:
Name Type Description
$direction int One of ezcImageGeometryFilters::SCALE_*
Exceptions:
Type Description
ezcBaseValueException If a submitted parameter was out of range or type.

noise

void noise( strings $value )

Noise filter.

Apply a noise transformation to the image. Valid values are the following strings:

  • 'Uniform'
  • 'Gaussian'
  • 'Multiplicative'
  • 'Impulse'
  • 'Laplacian'
  • 'Poisson'
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 ezcImageImagemagickHandler::applyFilter() method, which enables you to specify the image a filter is applied to.
Parameters:
Name Type Description
$value strings Noise value as described above.
Exceptions:
Type Description
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference.
ezcBaseValueException If the noise value is out of range.
Implementation of:
Method Description
ezcImageEffectFilters::noise() Noise filter.

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 ezcImageImagemagickHandler::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.
Exceptions:
Type Description
ezcBaseValueException If a submitted parameter was out of range or type.
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference.
Implementation of:
Method Description
ezcImageGeometryFilters::scale() Scale filter.

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 ezcImageImagemagickHandler::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
Exceptions:
Type Description
ezcBaseValueException If a submitted parameter was out of range or type.
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference.
Implementation of:
Method Description
ezcImageGeometryFilters::scaleExact() Scale exact filter.

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 ezcImageImagemagickHandler::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
Exceptions:
Type Description
ezcBaseValueException If a submitted parameter was out of range or type.
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference
Implementation of:
Method Description
ezcImageGeometryFilters::scaleHeight() Scale after height filter.

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 ezcImageImagemagickHandler::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
Exceptions:
Type Description
ezcBaseValueException If a submitted parameter was out of range or type.
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference
Implementation of:
Method Description
ezcImageGeometryFilters::scalePercent() Scale percent measures filter.

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 ezcImageImagemagickHandler::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
Exceptions:
Type Description
ezcBaseValueException If a submitted parameter was out of range or type.
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference
Implementation of:
Method Description
ezcImageGeometryFilters::scaleWidth() Scale after width filter.

swirl

void swirl( int $value )

Swirl filter.

Applies a swirl with the given intense to the image.

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 ezcImageImagemagickHandler::applyFilter() method, which enables you to specify the image a filter is applied to.

Parameters:
Name Type Description
$value int Intense of swirl.
Exceptions:
Type Description
ezcBaseValueException If the swirl value is out of range.
ezcImageInvalidReferenceException No loaded file could be found or an error destroyed a loaded reference.
Implementation of:
Method Description
ezcImageEffectFilters::swirl() Swirl filter.

watermarkAbsolute

void watermarkAbsolute( string $image , int $posX , int $posY , [int|bool $width = false] , [int|bool $height = false] )

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.

Parameters:
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.
Exceptions:
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.
Implementation of:
Method Description
ezcImageWatermarkFilters::watermarkAbsolute() Watermark filter.

watermarkPercent

void watermarkPercent( string $image , int $posX , int $posY , [int|bool $size = false] )

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.

Parameters:
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.
Exceptions:
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.
Implementation of:
Method Description
ezcImageWatermarkFilters::watermarkPercent() Watermark filter.
Documentation generated by phpDocumentor 1.4.3