Properties

$_im

$_im : resource

The underlaying image resource.

Type

resource

$_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

$_colors

$_colors : array<mixed,integer>

Allocated color resources.

Type

array<mixed,integer>

$_im

$_im : resource

GD image resource for the current image data.

Type

resource

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 —

A 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.

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.

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

Returns the raw data for this image.

Parameters

boolean $convert

Ignored for Gd driver.

array $options

Array of options:

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

Returns

string —

The raw image data.

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_Base

Returns a specific image from the pages of images.

Parameters

integer $index

The index to return.

Returns

\Horde_Image_Base

The requested image

getImagePageCount()

getImagePageCount() : integer

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

Returns

integer —

The number of images.

__get()

__get(  $property) 

Parameters

$property

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 (unused).

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.

yellowize()

yellowize(integer  $intensityY = 50, integer  $intensityB = 3) 

Applies a yellow filter.

Adds a layer of yellow that can be transparent or solid. If $intensityY is 255 the image will be 0% transparent (solid).

Parameters

integer $intensityY

How strong should the yellow (red and green) be? (0-255)

integer $intensityB

How weak should the blue be? (>= 2, in the positive limit it will be make BLUE 0)

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 = null) 

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 = 'black', 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 = 'black', string  $fill = 'none') 

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  $x1, integer  $y1,   $x2,   $y2, string  $color = 'black', string  $width = 1) 

Draws a line.

Parameters

integer $x1

The x coordinate of the end.

integer $y1

The y coordinate of the end.

$x2
$y2
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 = null) 

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

create()

create(integer  $width, integer  $height) : resource

Creates an image of the given size.

If possible the function returns a true color image.

Parameters

integer $width

The image width.

integer $height

The image height.

Throws

\Horde_Image_Exception

Returns

resource —

The image handler.

call()

call(string  $function, array  $params = null) : mixed

Wraps a call to a function of the gd extension.

Parameters

string $function

The name of the function to wrap.

array $params

An array with all parameters for that function.

Throws

\Horde_Image_Exception

Returns

mixed —

The result of the function call.

applyMask()

applyMask(resource  $mask) 

Applies the specified mask to the image.

Parameters

resource $mask

The gd image resource representing the mask

_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.

_allocateColor()

_allocateColor(string  $name, integer  $alpha) : integer

Creates a color that can be accessed in this object.

When a color is set, the integer resource of it is returned.

Parameters

string $name

The name of the color.

integer $alpha

Alpha transparency (0 - 127).

Returns

integer —

The resource of the color that can be passed to GD.

_getFont()

_getFont(string  $font) : integer

Returns the numeric font size a from textual description.

Parameters

string $font

A textual size description.

Returns

integer —

The font size supported by GD.