Properties

$imagick

$imagick : \Imagick

The underlaying Imagick object.

Type

\Imagick

$_background

$_background : string

Background color.

Type

string

$_capabilities

$_capabilities : array<mixed,string>

Capabilites of this driver.

Type

array<mixed,string>

$_data

$_data : \Horde_Stream

The current image data.

Type

\Horde_Stream

$_logger

$_logger : 

Logger.

Type

$_width

$_width : integer

The current width of the image data.

Type

integer

$_height

$_height : integer

The current height of the image data.

Type

integer

$_tmpdir

$_tmpdir : string

A directory for temporary files.

Type

string

$_loadedEffects

$_loadedEffects : array

Array containing available Effects

Type

array

$_type

$_type : string

What kind of images should ImageMagick generate? Defaults to 'png'.

Type

string

$_context

$_context : 

Cache the context

Type

$_imagick

$_imagick : \Imagick

The underlaying Imagick object.

Type

\Imagick

$_noMoreImages

$_noMoreImages : boolean

Flag for iterator, since calling nextImage on Imagick would result in a fatal error if there are no more images.

Type

boolean

Methods

__construct()

__construct(array  $params, array  $context = array()) 

Constructor.

Parameters

array $params

The image object parameters. Values include:

  • background: (string) The background color. DEFAULT: white.
  • data: (string) The image binary data.
  • height: (integer) The desired image height.
  • type: (string) The output image type (png, jpeg etc.). DEFAULT: png.
  • width: (integer) The desired image width.
array $context

The object context - configuration, injected objects:

  • logger: (Horde_Log_Logger) A logger.
  • tmpdir: [REQUIRED] (string) Temporary directory.

__call()

__call(  $method,   $args) 

Catch-all method so that we don't error out when calling an unsupported manipulation method.

Parameters

$method
$args

getCapabilities()

getCapabilities() : array

Returns the capabilities.

Returns

array —

A list of backend capabilities.

hasCapability()

hasCapability(string  $capability) : boolean

Checks the existence of a particular capability.

Parameters

string $capability

The capability to check for.

Returns

boolean —

True if the backend has this capability.

headers()

headers() 

Sends HTTP headers for the image.

getContentType()

getContentType() : string

Returns the MIME type for this image.

Returns

string —

The MIME type for this image.

getType()

getType() : string

Returns the image type.

Returns

string —

The type of this image (png, jpg, etc.).

setType()

setType(string  $type) : string

Sets the output image type.

Parameters

string $type

An image type (png, jpg, etc.)

Returns

string —

The previous image type.

brush()

brush(integer  $x, integer  $y, string  $color = 'black', string  $shape = 'square') 

Draws a shaped point at the specified (x,y) point.

Useful for scatter diagrams, debug points, etc. Draws squares, circles, diamonds, and triangles.

Parameters

integer $x

The x coordinate of the point to brush.

integer $y

The y coordinate of the point to brush.

string $color

The color to brush the point with.

string $shape

What brush to use? Defaults to a square.

reset()

reset() 

Resets the image data to defaults.

getDimensions()

getDimensions() : array

Returns the height and width of the current image data.

Returns

array —

An hash with 'width' containing the width, 'height' containing the height of the image.

loadString()

loadString(string  $image_data) 

Loads the image data from a string.

Parameters

string $image_data

The data to use for the image.

Throws

\Horde_Image_Exception

loadFile()

loadFile(string  $filename) 

Loads the image data from a file.

Parameters

string $filename

The full path and filename to the file to load the image data from.

Throws

\Horde_Image_Exception

toFile()

toFile(  $data = null) : string

Saves image data to file.

If $data is false-ish, saves current image data after performing pending operations on the data. If $data contains raw image data, saves that data to file without regard for the current image data.

Parameters

$data

Throws

\Horde_Image_Exception

Returns

string —

Path to temporary file.

display()

display() 

Displays the current image.

raw()

raw(boolean  $convert = false, array  $options = array()) : mixed

Returns the raw data for this image.

Parameters

boolean $convert

Ignored for Imagick driver.

array $options

Array of options:

  • stream: If true, return as a stream resource. DEFAULT: false.

Returns

mixed —

The raw image data as a string or stream resource.

addEffect()

addEffect(string  $type, array  $params) 

Attempts to apply requested effect to this image.

Parameters

string $type

The type of effect to apply.

array $params

Any parameters for the effect.

getLoadedEffects()

getLoadedEffects() 

Returns a list of available effects for this driver.

applyEffects()

applyEffects() 

Applies any effects in the effect queue.

getTmpDir()

getTmpDir() : string

Returns the current temporary directory.

Returns

string —

The current temporary directory.

clearGeometry()

clearGeometry() 

Utility function to zero out cached geometry information.

Shouldn't really be called from client code, but is needed since effects may need to clear these.

getImageAtIndex()

getImageAtIndex(integer  $index) : \Horde_Image_Imagick

Returns a specific image from the pages of images.

Parameters

integer $index

The index to return.

Returns

\Horde_Image_Imagick

The requested image

getImagePageCount()

getImagePageCount() : integer

Returns the number of image pages available in the image object.

Returns

integer —

The number of images.

resize()

resize(integer  $width, integer  $height, boolean  $ratio = true, boolean  $keepProfile = false) 

Resizes the current image.

Parameters

integer $width

The new width.

integer $height

The new height.

boolean $ratio

Maintain original aspect ratio.

boolean $keepProfile

Keep the image meta data.

crop()

crop(integer  $x1, integer  $y1, integer  $x2, integer  $y2) 

Crops the current image.

Parameters

integer $x1

x for the top left corner.

integer $y1

y for the top left corner.

integer $x2

x for the bottom right corner.

integer $y2

y for the bottom right corner.

rotate()

rotate(integer  $angle, string  $background = 'white') 

Rotates the current image.

Parameters

integer $angle

The angle to rotate the image by, in the clockwise direction.

string $background

The background color to fill any triangles.

flip()

flip() 

Flips the current image.

mirror()

mirror() 

Mirrors the current image.

grayscale()

grayscale() 

Converts the current image to grayscale.

sepia()

sepia(integer  $threshold = 85) 

Applies a sepia filter.

Parameters

integer $threshold

Extent of sepia effect.

text()

text(  $string, integer  $x, integer  $y, string  $font = '', string  $color = 'black', integer  $direction, string  $fontsize = 'small') 

Draws a text string on the image in a specified location, with the specified style information.

Parameters

$string
integer $x

The left x coordinate of the start of the text string.

integer $y

The top y coordinate of the start of the text string.

string $font

The font identifier you want to use for the text.

string $color

The color that you want the text displayed in.

integer $direction

An integer that specifies the orientation of the text.

string $fontsize

Size of the font (small, medium, large, giant)

circle()

circle(integer  $x, integer  $y, integer  $r, string  $color, string  $fill = 'none') 

Draws a circle.

Parameters

integer $x

The x coordinate of the centre.

integer $y

The y coordinate of the centre.

integer $r

The radius of the circle.

string $color

The line color of the circle.

string $fill

The color to fill the circle.

polygon()

polygon(  $verts, string  $color, string  $fill = 'none') 

Draws a polygon based on a set of vertices.

Parameters

$verts
string $color

The color you want to draw the polygon with.

string $fill

The color to fill the polygon.

rectangle()

rectangle(integer  $x, integer  $y, integer  $width, integer  $height, string  $color, string  $fill = 'none') 

Draws a rectangle.

Parameters

integer $x

The left x-coordinate of the rectangle.

integer $y

The top y-coordinate of the rectangle.

integer $width

The width of the rectangle.

integer $height

The height of the rectangle.

string $color

The line color of the rectangle.

string $fill

The color to fill the rectangle.

roundedRectangle()

roundedRectangle(integer  $x, integer  $y, integer  $width, integer  $height, integer  $round, string  $color, string  $fill) 

Draws a rounded rectangle.

Parameters

integer $x

The left x-coordinate of the rectangle.

integer $y

The top y-coordinate of the rectangle.

integer $width

The width of the rectangle.

integer $height

The height of the rectangle.

integer $round

The width of the corner rounding.

string $color

The line color of the rectangle.

string $fill

The color to fill the rounded rectangle with.

line()

line(integer  $x0, integer  $y0, integer  $x1, integer  $y1, string  $color = 'black', string  $width = 1) 

Draws a line.

Parameters

integer $x0

The x coordinate of the start.

integer $y0

The y coordinate of the start.

integer $x1

The x coordinate of the end.

integer $y1

The y coordinate of the end.

string $color

The line color.

string $width

The width of the line.

dashedLine()

dashedLine(integer  $x0, integer  $y0, integer  $x1, integer  $y1, string  $color = 'black', string  $width = 1, integer  $dash_length = 2, integer  $dash_space = 2) 

Draws a dashed line.

Parameters

integer $x0

The x co-ordinate of the start.

integer $y0

The y co-ordinate of the start.

integer $x1

The x co-ordinate of the end.

integer $y1

The y co-ordinate of the end.

string $color

The line color.

string $width

The width of the line.

integer $dash_length

The length of a dash on the dashed line.

integer $dash_space

The length of a space in the dashed line.

polyline()

polyline(  $verts, string  $color, string  $width = 1) 

Draws a polyline (a non-closed, non-filled polygon) based on a set of vertices.

Parameters

$verts
string $color

The color you want to draw the line with.

string $width

The width of the line.

arc()

arc(integer  $x, integer  $y, integer  $r, integer  $start, integer  $end, string  $color = 'black', string  $fill = 'none') 

Draws an arc.

Parameters

integer $x

The x coordinate of the centre.

integer $y

The y coordinate of the centre.

integer $r

The radius of the arc.

integer $start

The start angle of the arc.

integer $end

The end angle of the arc.

string $color

The line color of the arc.

string $fill

The fill color of the arc (defaults to none).

__get()

__get(  $property) 

Parameters

$property

frameImage()

frameImage(  $image, string  $color, integer  $width, integer  $height) 

Utility function to wrap Imagick::borderImage.

Use when you don't want to replace all pixels in the clipping area with the border color i.e. you want to "frame" the existing image. Preserves transparency etc.

Parameters

$image
string $color

The border color.

integer $width

The image width including the border.

integer $height

The image height including the border.

rewind()

rewind() 

Resets the Imagick iterator to the first image in the set.

current()

current() : \Horde_Image_Imagick

Returns the current image from the internal iterator.

Returns

\Horde_Image_Imagick

key()

key() : integer

Returns the index of the internal iterator.

Returns

integer

valid()

valid() : boolean

Deterimines if the current iterator item is valid.

Returns

boolean

cloneImagickObject()

cloneImagickObject(\Imagick  $imagick = null) : \Imagick

Wrapper around cloning the imagick resource object.

Parameters

\Imagick $imagick

A imagick resource object to clone. If empty will clone the imagick object associated with this Horde_Imagice_Imagick object.

Returns

\Imagick

_logDebug()

_logDebug(string  $message) 

Logs a message at debug level.

Parameters

string $message

The log message.

_logErr()

_logErr(string  $message) 

Logs a message at error level.

Parameters

string $message

The log message.