PHP Class Horde_Image_Gd, horde

Author: Chuck Hagenbuch ([email protected])
Author: Michael J. Rubinsky ([email protected])
Author: Jan Schneider ([email protected])
Inheritance: extends Horde_Image_Base
Mostra file Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_capabilities string[] Capabilites of this driver.
$_colors int[] Allocated color resources.
$_im resource GD image resource for the current image data.

Public Methods

Method Description
__construct ( $params, $context = [] ) Constructor.
__get ( $property )
applyMask ( resource $mask ) Applies the specified mask to the image.
arc ( integer $x, integer $y, integer $r, integer $start, integer $end, string $color = 'black', string $fill = null ) Draws an arc.
call ( string $function, array $params = null ) : mixed Wraps a call to a function of the gd extension.
circle ( integer $x, integer $y, integer $r, string $color, string $fill = null ) Draws a circle.
create ( integer $width, integer $height ) : resource Creates an image of the given size.
crop ( integer $x1, integer $y1, integer $x2, integer $y2 ) Crops the current image.
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.
display ( ) Displays the current image.
flip ( ) Flips the current image.
getDimensions ( ) : array Returns the height and width of the current image data.
grayscale ( ) Converts the current image to grayscale.
line ( integer $x1, integer $y1, $x2, $y2, string $color = 'black', string $width = 1 ) Draws a line.
loadFile ( string $filename ) Loads the image data from a file.
loadString ( string $image_data ) Loads the image data from a string.
mirror ( ) Mirrors the current image.
polygon ( $verts, string $color, string $fill = 'none' ) Draws a polygon based on a set of vertices.
polyline ( $verts, string $color, string $width = 1 ) Draws a polyline (a non-closed, non-filled polygon) based on a set of vertices.
raw ( boolean $convert = false ) : string Returns the raw data for this image.
rectangle ( integer $x, integer $y, integer $width, integer $height, string $color = 'black', string $fill = 'none' ) Draws a rectangle.
reset ( ) Resets the image data to defaults.
resize ( integer $width, integer $height, boolean $ratio = true, boolean $keepProfile = false ) Resizes the current image.
rotate ( integer $angle, string $background = 'white' ) Rotates the current image.
roundedRectangle ( integer $x, integer $y, integer $width, integer $height, integer $round, string $color = 'black', string $fill = 'none' ) Draws a rounded rectangle.
sepia ( integer $threshold = 85 ) Applies a sepia filter.
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.
yellowize ( integer $intensityY = 50, integer $intensityB = 3 ) Applies a yellow filter.

Private Methods

Method Description
_allocateColor ( string $name, integer $alpha ) : integer Creates a color that can be accessed in this object.
_getFont ( string $font ) : integer Returns the numeric font size a from textual description.

Method Details

__construct() public method

Constructor.
See also: Horde_Image_Base::_construct
public __construct ( $params, $context = [] )

__get() public method

public __get ( $property )

applyMask() public method

Applies the specified mask to the image.
public applyMask ( resource $mask )
$mask resource The gd image resource representing the mask

arc() public method

Draws an arc.
public arc ( integer $x, integer $y, integer $r, integer $start, integer $end, string $color = 'black', string $fill = null )
$x integer The x coordinate of the centre.
$y integer The y coordinate of the centre.
$r integer The radius of the arc.
$start integer The start angle of the arc.
$end integer The end angle of the arc.
$color string The line color of the arc.
$fill string The fill color of the arc (defaults to none).

call() public method

Wraps a call to a function of the gd extension.
public call ( string $function, array $params = null ) : mixed
$function string The name of the function to wrap.
$params array An array with all parameters for that function.
return mixed The result of the function call.

circle() public method

Draws a circle.
public circle ( integer $x, integer $y, integer $r, string $color, string $fill = null )
$x integer The x coordinate of the centre.
$y integer The y coordinate of the centre.
$r integer The radius of the circle.
$color string The line color of the circle.
$fill string The color to fill the circle.

create() public method

If possible the function returns a true color image.
public create ( integer $width, integer $height ) : resource
$width integer The image width.
$height integer The image height.
return resource The image handler.

crop() public method

Crops the current image.
public crop ( integer $x1, integer $y1, integer $x2, integer $y2 )
$x1 integer x for the top left corner.
$y1 integer y for the top left corner.
$x2 integer x for the bottom right corner.
$y2 integer y for the bottom right corner.

dashedLine() public method

Draws a dashed line.
public dashedLine ( integer $x0, integer $y0, integer $x1, integer $y1, string $color = 'black', string $width = 1, integer $dash_length = 2, integer $dash_space = 2 )
$x0 integer The x co-ordinate of the start.
$y0 integer The y co-ordinate of the start.
$x1 integer The x co-ordinate of the end.
$y1 integer The y co-ordinate of the end.
$color string The line color.
$width string The width of the line.
$dash_length integer The length of a dash on the dashed line.
$dash_space integer The length of a space in the dashed line.

display() public method

Displays the current image.
public display ( )

flip() public method

Flips the current image.
public flip ( )

getDimensions() public method

Returns the height and width of the current image data.
public getDimensions ( ) : array
return array An hash with 'width' containing the width, 'height' containing the height of the image.

grayscale() public method

Converts the current image to grayscale.
public grayscale ( )

line() public method

Draws a line.
public line ( integer $x1, integer $y1, $x2, $y2, string $color = 'black', string $width = 1 )
$x1 integer The x coordinate of the end.
$y1 integer The y coordinate of the end.
$color string The line color.
$width string The width of the line.

loadFile() public method

Loads the image data from a file.
public loadFile ( string $filename )
$filename string The full path and filename to the file to load the image data from.

loadString() public method

Loads the image data from a string.
public loadString ( string $image_data )
$image_data string The data to use for the image.

mirror() public method

Mirrors the current image.
public mirror ( )

polygon() public method

Draws a polygon based on a set of vertices.
public polygon ( $verts, string $color, string $fill = 'none' )
$color string The color you want to draw the polygon with.
$fill string The color to fill the polygon.

polyline() public method

Draws a polyline (a non-closed, non-filled polygon) based on a set of vertices.
public polyline ( $verts, string $color, string $width = 1 )
$color string The color you want to draw the line with.
$width string The width of the line.

raw() public method

Returns the raw data for this image.
public raw ( boolean $convert = false ) : string
$convert boolean Ignored for Gd driver.
return string The raw image data.

rectangle() public method

Draws a rectangle.
public rectangle ( integer $x, integer $y, integer $width, integer $height, string $color = 'black', string $fill = 'none' )
$x integer The left x-coordinate of the rectangle.
$y integer The top y-coordinate of the rectangle.
$width integer The width of the rectangle.
$height integer The height of the rectangle.
$color string The line color of the rectangle.
$fill string The color to fill the rectangle.

reset() public method

Resets the image data to defaults.
public reset ( )

resize() public method

Resizes the current image.
public resize ( integer $width, integer $height, boolean $ratio = true, boolean $keepProfile = false )
$width integer The new width.
$height integer The new height.
$ratio boolean Maintain original aspect ratio.
$keepProfile boolean Keep the image meta data (unused).

rotate() public method

Rotates the current image.
public rotate ( integer $angle, string $background = 'white' )
$angle integer The angle to rotate the image by, in the clockwise direction.
$background string The background color to fill any triangles.

roundedRectangle() public method

Draws a rounded rectangle.
public roundedRectangle ( integer $x, integer $y, integer $width, integer $height, integer $round, string $color = 'black', string $fill = 'none' )
$x integer The left x-coordinate of the rectangle.
$y integer The top y-coordinate of the rectangle.
$width integer The width of the rectangle.
$height integer The height of the rectangle.
$round integer The width of the corner rounding.
$color string The line color of the rectangle.
$fill string The color to fill the rounded rectangle with.

sepia() public method

Applies a sepia filter.
public sepia ( integer $threshold = 85 )
$threshold integer Extent of sepia effect.

text() public method

Draws a text string on the image in a specified location, with the specified style information.
public text ( $string, integer $x, integer $y, string $font = '', string $color = 'black', integer $direction, string $fontsize = 'small' )
$x integer The left x coordinate of the start of the text string.
$y integer 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 The color that you want the text displayed in.
$direction integer An integer that specifies the orientation of the text.
$fontsize string Size of the font (small, medium, large, giant)

yellowize() public method

Adds a layer of yellow that can be transparent or solid. If $intensityY is 255 the image will be 0% transparent (solid).
public yellowize ( integer $intensityY = 50, integer $intensityB = 3 )
$intensityY integer How strong should the yellow (red and green) be? (0-255)
$intensityB integer How weak should the blue be? (>= 2, in the positive limit it will be make BLUE 0)

Property Details

$_capabilities protected_oe property

Capabilites of this driver.
protected string[] $_capabilities
return string[]

$_colors protected_oe property

Allocated color resources.
protected int[] $_colors
return int[]

$_im protected_oe property

GD image resource for the current image data.
protected resource $_im
return resource