Horde_Image_Im
extends Horde_Image_Base
in package
ImageMagick driver for the Horde_Image API.
Tags
Table of Contents
- $imagick : Imagick
- $_background : string
- Background color.
- $_capabilities : array<string|int, string>
- Capabilites of this driver.
- $_context : mixed
- Cache the context
- $_convert : string
- Path to the convert binary.
- $_data : Horde_Stream
- The current image data.
- $_height : int
- The current height of the image data.
- $_identify : string
- Path to the identify binary.
- $_loadedEffects : array<string|int, mixed>
- Array containing available Effects
- $_logger : mixed
- Logger.
- $_operations : array<string|int, mixed>
- Operations to be performed before the source filename is specified on the command line.
- $_postSrcOperations : array<string|int, mixed>
- Operations to be added after the source filename is specified on the command line.
- $_tmpdir : string
- A directory for temporary files.
- $_toClean : array<string|int, mixed>
- An array of temporary filenames that need to be unlinked at the end of processing.
- $_type : string
- What kind of images should ImageMagick generate? Defaults to 'png'.
- $_width : int
- The current width of the image data.
- $_currentPage : int
- The current page for the iterator.
- $_pages : int
- Cache for the number of image pages.
- __call() : mixed
- Catch-all method so that we don't error out when calling an unsupported manipulation method.
- __construct() : mixed
- Constructor.
- addEffect() : mixed
- Attempts to apply requested effect to this image.
- addFileToClean() : mixed
- addOperation() : mixed
- addPostSrcOperation() : mixed
- applyEffects() : mixed
- Applies any effects in the effect queue.
- arc() : mixed
- Draws an arc.
- brush() : mixed
- Draws a shaped point at the specified (x,y) point.
- circle() : mixed
- Draws a circle.
- clearGeometry() : mixed
- Utility function to zero out cached geometry information.
- crop() : mixed
- Crops the current image.
- current() : Horde_Image_Imagick
- Return the current image from the internal iterator.
- dashedLine() : mixed
- Draws a dashed line.
- display() : mixed
- Displays the current image.
- executeConvertCmd() : mixed
- Method to execute a raw command directly in convert.
- flattenImage() : mixed
- Flatten this image and remove transparency.
- flip() : mixed
- Flips the current image.
- getCapabilities() : array<string|int, mixed>
- Returns the capabilities.
- getContentType() : string
- Returns the MIME type for this image.
- getConvertPath() : mixed
- getDimensions() : array<string|int, mixed>
- Returns the height and width of the current image data.
- getImageAtIndex() : Horde_Image_Base
- Request a specific image from the collection of images.
- getImagePageCount() : int
- Return the number of image pages available in the image object.
- getIMVersion() : string
- Returns the version of the convert command available.
- getLoadedEffects() : mixed
- Returns a list of available effects for this driver.
- getTmpDir() : string
- Returns the current temporary directory.
- getType() : string
- Returns the image type.
- grayscale() : mixed
- Converts the current image to grayscale.
- hasCapability() : bool
- Checks the existence of a particular capability.
- headers() : mixed
- Sends HTTP headers for the image.
- key() : int
- Get the index of the internal iterator.
- line() : mixed
- Draws a line.
- loadFile() : mixed
- Loads the image data from a file.
- loadString() : mixed
- Loads the image data from a string.
- mirror() : mixed
- Mirrors the current image.
- next() : Horde_Image_Im
- Advance the iterator
- polygon() : mixed
- Draws a polygon based on a set of vertices.
- polyline() : mixed
- Draws a polyline (a non-closed, non-filled polygon) based on a set of vertices.
- raw() : mixed
- Returns the raw data for this image.
- rectangle() : mixed
- Draws a rectangle.
- reset() : mixed
- Resets the image data.
- resize() : mixed
- Resizes the current image.
- rewind() : void
- Reset the imagick iterator to the first image in the set.
- rotate() : mixed
- Rotates the current image.
- roundedRectangle() : mixed
- Draws a rounded rectangle.
- sepia() : mixed
- Applies a sepia filter.
- setType() : string
- Sets the output image type.
- text() : mixed
- Draws a text string on the image in a specified location, with the specified style information.
- toFile() : string
- Saves image data to file.
- valid() : bool
- Deterimines if the current iterator item is valid.
- _logDebug() : mixed
- Logs a message at debug level.
- _logErr() : mixed
- Logs a message at error level.
- _getImagePages() : mixed
- _raw() : Horde_Stream
- Returns the raw data for this image.
Properties
$imagick read-only
public
Imagick
$imagick
The underlaying Imagick object.
$_background
Background color.
protected
string
$_background
= 'white'
$_capabilities
Capabilites of this driver.
protected
array<string|int, string>
$_capabilities
= array('arc', 'canvas', 'circle', 'crop', 'dashedLine', 'flip', 'grayscale', 'line', 'mirror', 'multipage', 'pdf', 'polygon', 'polyline', 'rectangle', 'resize', 'rotate', 'roundedRectangle', 'sepia', 'text')
$_context
Cache the context
protected
mixed
$_context
$_convert
Path to the convert binary.
protected
string
$_convert
= ''
$_data
The current image data.
protected
Horde_Stream
$_data
$_height
The current height of the image data.
protected
int
$_height
= 0
$_identify
Path to the identify binary.
protected
string
$_identify
$_loadedEffects
Array containing available Effects
protected
array<string|int, mixed>
$_loadedEffects
= array()
$_logger
Logger.
protected
mixed
$_logger
$_operations
Operations to be performed before the source filename is specified on the command line.
protected
array<string|int, mixed>
$_operations
= array()
$_postSrcOperations
Operations to be added after the source filename is specified on the command line.
protected
array<string|int, mixed>
$_postSrcOperations
= array()
$_tmpdir
A directory for temporary files.
protected
string
$_tmpdir
$_toClean
An array of temporary filenames that need to be unlinked at the end of processing.
protected
array<string|int, mixed>
$_toClean
= array()
Use addFileToClean() from client code (effects) to add files to this array.
$_type
What kind of images should ImageMagick generate? Defaults to 'png'.
protected
string
$_type
= 'png'
$_width
The current width of the image data.
protected
int
$_width
= 0
$_currentPage
The current page for the iterator.
private
int
$_currentPage
= 0
$_pages
Cache for the number of image pages.
private
int
$_pages
Methods
__call()
Catch-all method so that we don't error out when calling an unsupported manipulation method.
public
__call(mixed $method, mixed $args) : mixed
Parameters
- $method : mixed
- $args : mixed
Return values
mixed —__construct()
Constructor.
public
__construct(mixed $params[, mixed $context = array() ]) : mixed
Parameters
- $params : mixed
-
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.
- $context : mixed = array()
-
The object context - configuration, injected objects:
- logger: (Horde_Log_Logger) A logger.
- tmpdir: [REQUIRED] (string) Temporary directory.
Tags
Return values
mixed —addEffect()
Attempts to apply requested effect to this image.
public
addEffect(string $type, array<string|int, mixed> $params) : mixed
Parameters
- $type : string
-
The type of effect to apply.
- $params : array<string|int, mixed>
-
Any parameters for the effect.
Return values
mixed —addFileToClean()
public
addFileToClean(mixed $filename) : mixed
Parameters
- $filename : mixed
Return values
mixed —addOperation()
public
addOperation(mixed $operation) : mixed
Parameters
- $operation : mixed
Return values
mixed —addPostSrcOperation()
public
addPostSrcOperation(mixed $operation) : mixed
Parameters
- $operation : mixed
Return values
mixed —applyEffects()
Applies any effects in the effect queue.
public
applyEffects() : mixed
Return values
mixed —arc()
Draws an arc.
public
arc(int $x, int $y, int $r, int $start, int $end[, string $color = 'black' ][, string $fill = 'none' ]) : mixed
Parameters
- $x : int
-
The x coordinate of the centre.
- $y : int
-
The y coordinate of the centre.
- $r : int
-
The radius of the arc.
- $start : int
-
The start angle of the arc.
- $end : int
-
The end angle of the arc.
- $color : string = 'black'
-
The line color of the arc.
- $fill : string = 'none'
-
The fill color of the arc (defaults to none).
Return values
mixed —brush()
Draws a shaped point at the specified (x,y) point.
public
brush(int $x, int $y[, string $color = 'black' ][, string $shape = 'square' ]) : mixed
Useful for scatter diagrams, debug points, etc. Draws squares, circles, diamonds, and triangles.
Parameters
- $x : int
-
The x coordinate of the point to brush.
- $y : int
-
The y coordinate of the point to brush.
- $color : string = 'black'
-
The color to brush the point with.
- $shape : string = 'square'
-
What brush to use? Defaults to a square.
Return values
mixed —circle()
Draws a circle.
public
circle(int $x, int $y, int $r, string $color[, string $fill = 'none' ]) : mixed
Parameters
- $x : int
-
The x coordinate of the centre.
- $y : int
-
The y coordinate of the centre.
- $r : int
-
The radius of the circle.
- $color : string
-
The line color of the circle.
- $fill : string = 'none'
-
The color to fill the circle.
Return values
mixed —clearGeometry()
Utility function to zero out cached geometry information.
public
clearGeometry() : mixed
Shouldn't really be called from client code, but is needed since effects may need to clear these.
Return values
mixed —crop()
Crops the current image.
public
crop(int $x1, int $y1, int $x2, int $y2) : mixed
Parameters
- $x1 : int
-
x for the top left corner.
- $y1 : int
-
y for the top left corner.
- $x2 : int
-
x for the bottom right corner.
- $y2 : int
-
y for the bottom right corner.
Return values
mixed —current()
Return the current image from the internal iterator.
public
current() : Horde_Image_Imagick
Return values
Horde_Image_Imagick —dashedLine()
Draws a dashed line.
public
dashedLine(int $x0, int $y0, int $x1, int $y1[, string $color = 'black' ][, string $width = 1 ][, int $dash_length = 2 ][, int $dash_space = 2 ]) : mixed
Parameters
- $x0 : int
-
The x co-ordinate of the start.
- $y0 : int
-
The y co-ordinate of the start.
- $x1 : int
-
The x co-ordinate of the end.
- $y1 : int
-
The y co-ordinate of the end.
- $color : string = 'black'
-
The line color.
- $width : string = 1
-
The width of the line.
- $dash_length : int = 2
-
The length of a dash on the dashed line
- $dash_space : int = 2
-
The length of a space in the dashed line
Return values
mixed —display()
Displays the current image.
public
display() : mixed
Return values
mixed —executeConvertCmd()
Method to execute a raw command directly in convert.
public
executeConvertCmd(string $cmd[, array<string|int, mixed> $values = array() ]) : mixed
Useful for executing more involved operations that may require multiple convert commands piped into each other as could be needed by Im based Horde_Image_Effect objects.
The input and output files are quoted and substituted for FILEIN and FILEOUT respectfully. In order to support piped convert commands, the path to the convert command is substitued for CONVERT (but the initial convert command is added automatically).
Parameters
- $cmd : string
-
The command string, with substitutable tokens
- $values : array<string|int, mixed> = array()
-
Any values that should be substituted for tokens.
Return values
mixed —flattenImage()
Flatten this image and remove transparency.
public
flattenImage([string $bgColor = 'white' ]) : mixed
Parameters
- $bgColor : string = 'white'
-
The background color to use.
Return values
mixed —flip()
Flips the current image.
public
flip() : mixed
Return values
mixed —getCapabilities()
Returns the capabilities.
public
getCapabilities() : array<string|int, mixed>
Return values
array<string|int, mixed> —A list of backend capabilities.
getContentType()
Returns the MIME type for this image.
public
getContentType() : string
Return values
string —The MIME type for this image.
getConvertPath()
public
getConvertPath() : mixed
Return values
mixed —getDimensions()
Returns the height and width of the current image data.
public
getDimensions() : array<string|int, mixed>
Return values
array<string|int, mixed> —An hash with 'width' containing the width, 'height' containing the height of the image.
getImageAtIndex()
Request a specific image from the collection of images.
public
getImageAtIndex(int $index[, bool $flatten = false ][, string $bgColor = 'white' ]) : Horde_Image_Base
Parameters
- $index : int
-
The index to return
- $flatten : bool = false
-
If true, flatten the returned image using $bgColor as the background color. Useful for PDF files to remove transparency before rendering.
- $bgColor : string = 'white'
-
The background color to use when flattening the image.
Return values
Horde_Image_Base —getImagePageCount()
Return the number of image pages available in the image object.
public
getImagePageCount() : int
Return values
int —getIMVersion()
Returns the version of the convert command available.
public
getIMVersion() : string
This needs to be publicly visable since it's used by various effects.
Return values
string —A version string suitable for using in version_compare().
getLoadedEffects()
Returns a list of available effects for this driver.
public
getLoadedEffects() : mixed
Return values
mixed —getTmpDir()
Returns the current temporary directory.
public
getTmpDir() : string
Return values
string —The current temporary directory.
getType()
Returns the image type.
public
getType() : string
Return values
string —The type of this image (png, jpg, etc.).
grayscale()
Converts the current image to grayscale.
public
grayscale() : mixed
Return values
mixed —hasCapability()
Checks the existence of a particular capability.
public
hasCapability(string $capability) : bool
Parameters
- $capability : string
-
The capability to check for.
Return values
bool —True if the backend has this capability.
headers()
Sends HTTP headers for the image.
public
headers() : mixed
Return values
mixed —key()
Get the index of the internal iterator.
public
key() : int
Return values
int —line()
Draws a line.
public
line(int $x0, int $y0, int $x1, int $y1[, string $color = 'black' ][, string $width = 1 ]) : mixed
Parameters
- $x0 : int
-
The x coordinate of the start.
- $y0 : int
-
The y coordinate of the start.
- $x1 : int
-
The x coordinate of the end.
- $y1 : int
-
The y coordinate of the end.
- $color : string = 'black'
-
The line color.
- $width : string = 1
-
The width of the line.
Return values
mixed —loadFile()
Loads the image data from a file.
public
loadFile(string $filename) : mixed
Parameters
- $filename : string
-
The full path and filename to the file to load the image data from.
Tags
Return values
mixed —loadString()
Loads the image data from a string.
public
loadString(mixed $image_data) : mixed
Parameters
- $image_data : mixed
-
The data to use for the image as a string, Horde_Stream, or stream resource.
Return values
mixed —mirror()
Mirrors the current image.
public
mirror() : mixed
Return values
mixed —next()
Advance the iterator
public
next() : Horde_Image_Im
Return values
Horde_Image_Im —polygon()
Draws a polygon based on a set of vertices.
public
polygon(mixed $verts, string $color[, string $fill = 'none' ]) : mixed
Parameters
- $verts : mixed
- $color : string
-
The color you want to draw the polygon with.
- $fill : string = 'none'
-
The color to fill the polygon.
Return values
mixed —polyline()
Draws a polyline (a non-closed, non-filled polygon) based on a set of vertices.
public
polyline(mixed $verts, string $color[, string $width = 1 ]) : mixed
Parameters
- $verts : mixed
- $color : string
-
The color you want to draw the line with.
- $width : string = 1
-
The width of the line.
Return values
mixed —raw()
Returns the raw data for this image.
public
raw([bool $convert = false ][, array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $convert : bool = false
-
If true, the image data will be returned in the target format, independently from any image operations.
- $options : array<string|int, mixed> = array()
-
Array of options:
- stream: If true, return as a stream resource. DEFAULT: false.
Return values
mixed —The raw image data either as a string or stream resource.
rectangle()
Draws a rectangle.
public
rectangle(int $x, int $y, int $width, int $height, string $color[, string $fill = 'none' ]) : mixed
Parameters
- $x : int
-
The left x-coordinate of the rectangle.
- $y : int
-
The top y-coordinate of the rectangle.
- $width : int
-
The width of the rectangle.
- $height : int
-
The height of the rectangle.
- $color : string
-
The line color of the rectangle.
- $fill : string = 'none'
-
The color to fill the rectangle.
Return values
mixed —reset()
Resets the image data.
public
reset() : mixed
Return values
mixed —resize()
Resizes the current image.
public
resize(int $width, int $height[, bool $ratio = true ][, bool $keepProfile = false ]) : mixed
Parameters
- $width : int
-
The new width.
- $height : int
-
The new height.
- $ratio : bool = true
-
Maintain original aspect ratio.
- $keepProfile : bool = false
-
Keep the image meta data.
Return values
mixed —rewind()
Reset the imagick iterator to the first image in the set.
public
rewind() : void
Return values
void —rotate()
Rotates the current image.
public
rotate(int $angle[, int $background = 'white' ]) : mixed
Parameters
- $angle : int
-
The angle to rotate the image by, in the clockwise direction.
- $background : int = 'white'
-
The background color to fill any triangles.
Return values
mixed —roundedRectangle()
Draws a rounded rectangle.
public
roundedRectangle(int $x, int $y, int $width, int $height, int $round, string $color, string $fill) : mixed
Parameters
- $x : int
-
The left x-coordinate of the rectangle.
- $y : int
-
The top y-coordinate of the rectangle.
- $width : int
-
The width of the rectangle.
- $height : int
-
The height of the rectangle.
- $round : int
-
The width of the corner rounding.
- $color : string
-
The line color of the rectangle.
- $fill : string
-
The color to fill the rounded rectangle with.
Return values
mixed —sepia()
Applies a sepia filter.
public
sepia([int $threshold = 85 ]) : mixed
Parameters
- $threshold : int = 85
-
Extent of sepia effect.
Return values
mixed —setType()
Sets the output image type.
public
setType(string $type) : string
Parameters
- $type : string
-
An image type (png, jpg, etc.)
Return values
string —The previous image type.
text()
Draws a text string on the image in a specified location, with the specified style information.
public
text(mixed $string, int $x, int $y[, string $font = '' ][, string $color = 'black' ], int $direction[, string $fontsize = 'small' ]) : mixed
Parameters
- $string : mixed
- $x : int
-
The left x coordinate of the start of the text string.
- $y : int
-
The top y coordinate of the start of the text string.
- $font : string = ''
-
The font identifier you want to use for the text.
- $color : string = 'black'
-
The color that you want the text displayed in.
- $direction : int
-
An integer that specifies the orientation of the text.
- $fontsize : string = 'small'
-
Size of the font (small, medium, large, giant)
Tags
Return values
mixed —toFile()
Saves image data to file.
public
toFile([mixed $data = null ]) : string
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 : mixed = null
Tags
Return values
string —Path to temporary file.
valid()
Deterimines if the current iterator item is valid.
public
valid() : bool
Return values
bool —_logDebug()
Logs a message at debug level.
protected
_logDebug(string $message) : mixed
Parameters
- $message : string
-
The log message.
Return values
mixed —_logErr()
Logs a message at error level.
protected
_logErr(string $message) : mixed
Parameters
- $message : string
-
The log message.
Return values
mixed —_getImagePages()
private
_getImagePages() : mixed
Return values
mixed —_raw()
Returns the raw data for this image.
private
_raw([bool $convert = false ][, array<string|int, mixed> $options = array() ]) : Horde_Stream
Parameters
- $convert : bool = false
-
If true, the image data will be returned in the target format, independently from any image operations.
- $options : array<string|int, mixed> = array()
-
An array of options:
- index: (integer) An image index.
- preserve_data (boolean) If true, return the converted image but preserve the internal image data.
Return values
Horde_Stream —The data, in a Horde_Stream object.