Class Horde_Image_gd

Description

This class implements the Horde_Image:: API for the PHP GD extension. It mainly provides some utility functions, such as the ability to make pixels, for now.

$Horde: framework/Image/Image/gd.php,v 1.48.10.25 2010-09-05 16:51:39 mrubinsk Exp $

Copyright 2002-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /Image/Image/gd.php (line 21)

Horde_Image
   |
   --Horde_Image_gd
Variable Summary
 resource $_im
Method Summary
 Horde_Image_gd Horde_Image_gd ( $params)
 void arc (integer $x, integer $y, integer $r, integer $start, integer $end, [string $color = 'black'], [string $fill = null])
 void circle (integer $x, integer $y, integer $r, string $color, [string $fill = null])
 void crop (integer $x1, integer $y1, integer $x2, integer $y2)
 void dashedLine (integer $x0, integer $y0, integer $x1, integer $y1, [string $color = 'black'], [string $width = 1], [integer $dash_length = 2], [integer $dash_space = 2])
 void display ()
 void flip ()
 void getContentType ()
 array getDimensions ()
 void getFont ( $font)
 void grayscale ()
 void line (integer $x1, integer $y1,  $x2,  $y2, [string $color = 'black'], [string $width = 1], integer $x0, integer $y0)
 mixed loadFile (string $filename)
 PEAR_Error loadString (string $id, string $image_data)
 void mirror ()
 void polygon ( $verts, string $color, [string $fill = 'none'], array $vertices)
 void polyline ( $verts, string $color, [string $width = 1], array $vertices)
 string raw ([boolean $convert = false])
 void rectangle (integer $x, integer $y, integer $width, integer $height, [string $color = 'black'], [string $fill = 'none'])
 void reset ()
 PEAR_Error resize (integer $width, integer $height, [boolean $ratio = true])
 void rotate (integer $angle, [integer $background = 'white'])
 void roundedRectangle (integer $x, integer $y, integer $width, integer $height, integer $round, [string $color = 'black'], [string $fill = 'none'])
 void sepia ()
 void text ( $string, integer $x, integer $y, [string $font = 'monospace'], [string $color = 'black'], [integer $direction = 0], [ $fontsize = 'small'], string $text)
 void yellowize ([integer $intensityY = 50], [integer $intensityB = 3])
 integer _allocateColor (string $name)
 void _allocateColorAlpha ( $gdimg_hexcolorallocate,  $r,  $g,  $b, [ $alpha = false])
 mixed _applyMask (resource $gdimg_mask)
 mixed &_call (string $function, [array $params = null])
 resource|object PEAR &_create (integer $width, integer $height)
 void _grayscalePixel ( $OriginalPixel)
 void _grayscaleValue ( $r,  $g,  $b)
Variables
array $_capabilities = array('resize',
'crop',
'rotate',
'flip',
'mirror',
'grayscale',
'sepia',
'yellowize',
'canvas',
)
(line 28)

Capabilites of this driver.


Redefinition of:
Horde_Image::$_capabilities
Capabilites of this driver.
resource $_im (line 44)

GD Image resource for the current image data.

Inherited Variables

Inherited from Horde_Image

Horde_Image::$_background
Horde_Image::$_data
Horde_Image::$_height
Horde_Image::$_loadedEffects
Horde_Image::$_observers
Horde_Image::$_rgb
Horde_Image::$_tmpdir
Horde_Image::$_type
Horde_Image::$_width
Methods
Constructor Horde_Image_gd (line 47)
Horde_Image_gd Horde_Image_gd ( $params)
  • $params
arc (line 883)

Draw an arc.

void arc (integer $x, integer $y, integer $r, integer $start, integer $end, [string $color = 'black'], [string $fill = null])
  • integer $x: The x co-ordinate of the centre.
  • integer $y: The y co-ordinate 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).
circle (line 567)

Draw a circle.

void circle (integer $x, integer $y, integer $r, string $color, [string $fill = null])
  • integer $x: The x co-ordinate of the centre.
  • integer $y: The y co-ordinate 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.
crop (line 304)

Crop the current image.

void crop (integer $x1, integer $y1, integer $x2, integer $y2)
  • integer $x1: The top left corner of the cropped image.
  • integer $y1: The top right corner of the cropped image.
  • integer $x2: The bottom left corner of the cropped image.
  • integer $y2: The bottom right corner of the cropped image.
dashedLine (line 818)

Draw a dashed line.

void dashedLine (integer $x0, integer $y0, integer $x1, integer $y1, [string $color = 'black'], [string $width = 1], [integer $dash_length = 2], [integer $dash_space = 2])
  • 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
display (line 73)

Display the current image.

void display ()

Redefinition of:
Horde_Image::display()
Display the current image.
flip (line 383)

Flip the current image.

void flip ()
getContentType (line 65)
void getContentType ()
getDimensions (line 114)

Get the height and width of the current image.

  • return: An hash with 'width' containing the width, 'height' containing the height of the image.
array getDimensions ()

Redefinition of:
Horde_Image::getDimensions()
Get the height and width of the current image data.
getFont (line 152)
void getFont ( $font)
  • $font
grayscale (line 425)

Convert the current image to grayscale.

void grayscale ()
line (line 768)

Draw a line.

void line (integer $x1, integer $y1,  $x2,  $y2, [string $color = 'black'], [string $width = 1], integer $x0, integer $y0)
  • 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.
  • $x2
  • $y2
loadFile (line 204)

Load the image data from a file.

  • return: PEAR Error if file does not exist or could not be loaded otherwise NULL if successful or already loaded.
mixed loadFile (string $filename)
  • string $filename: The full path and filename to the file to load the image data from. The filename will also be used for the image id.

Redefinition of:
Horde_Image::loadFile()
Load the image data from a file.
loadString (line 181)

Load the image data from a string.

  • return: if image data could not be loaded.
PEAR_Error loadString (string $id, string $image_data)
  • string $id: An arbitrary id for the image.
  • string $image_data: The data to use for the image.

Redefinition of:
Horde_Image::loadString()
Load the image data from a string.
mirror (line 404)

Mirror the current image.

void mirror ()
polygon (line 602)

Draw a polygon based on a set of vertices.

void polygon ( $verts, string $color, [string $fill = 'none'], array $vertices)
  • array $vertices: An array of x and y labeled arrays (eg. $vertices[0]['x'], $vertices[0]['y'], ...).
  • string $color: The color you want to draw the polygon with.
  • string $fill: The color to fill the polygon.
  • $verts
polyline (line 856)

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

void polyline ( $verts, string $color, [string $width = 1], array $vertices)
  • array $vertices: An array of x and y labeled arrays (eg. $vertices[0]['x'], $vertices[0]['y'], ...).
  • string $color: The color you want to draw the line with.
  • string $width: The width of the line.
  • $verts
raw (line 88)

Returns the raw data for this image.

  • return: The raw image data.
string raw ([boolean $convert = false])
  • boolean $convert: If true, the image data will be returned in the target format, independently from any image operations.

Redefinition of:
Horde_Image::raw()
Returns the raw data for this image.
rectangle (line 641)

Draw a rectangle.

void rectangle (integer $x, integer $y, integer $width, integer $height, [string $color = 'black'], [string $fill = 'none'])
  • 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 with.
reset (line 99)

Reset the image data.

void reset ()

Redefinition of:
Horde_Image::reset()
Reset the image data.
resize (line 262)

Resize the current image.

  • return: on failure
PEAR_Error resize (integer $width, integer $height, [boolean $ratio = true])
  • integer $width: The new width.
  • integer $height: The new height.
  • boolean $ratio: Maintain original aspect ratio.
rotate (line 323)

Rotate the current image.

void rotate (integer $angle, [integer $background = 'white'])
  • integer $angle: The angle to rotate the image by, in the clockwise direction
  • integer $background: The background color to fill any triangles
roundedRectangle (line 675)

Draw a rounded rectangle.

void roundedRectangle (integer $x, integer $y, integer $width, integer $height, integer $round, [string $color = 'black'], [string $fill = 'none'])
  • 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.
sepia (line 458)

Sepia filter.

Basically turns the image to grayscale and then adds some defined tint on it (R += 30, G += 43, B += -23) so it will appear to be a very old picture.

void sepia ()
text (line 537)

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

void text ( $string, integer $x, integer $y, [string $font = 'monospace'], [string $color = 'black'], [integer $direction = 0], [ $fontsize = 'small'], string $text)
  • string $text: The text to draw.
  • 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
yellowize (line 499)

Yellowize filter.

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

void yellowize ([integer $intensityY = 50], [integer $intensityB = 3])
  • 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)
_allocateColor (line 140)

Creates a color that can be accessed in this object. When a color is set, the integer resource of it is returned.

  • return: The resource of the color that can be passed to GD.
integer _allocateColor (string $name)
  • string $name: The name of the color.
_allocateColorAlpha (line 1043)
void _allocateColorAlpha ( $gdimg_hexcolorallocate,  $r,  $g,  $b, [ $alpha = false])
  • $gdimg_hexcolorallocate
  • $r
  • $g
  • $b
  • $alpha
_applyMask (line 915)

Applies the specified mask to the image.

  • return: true | PEAR_Error
mixed _applyMask (resource $gdimg_mask)
  • resource $gdimg_mask: The gd image resource representing the mask
_call (line 1065)

Wraps a call to a function of the gd extension.

If the call produces an error, a PEAR_Error is returned, the function result otherwise.

  • return: Either the function result or a PEAR_Error if an error occured when executing the function.
mixed &_call (string $function, [array $params = null])
  • string $function: The name of the function to wrap.
  • array $params: An array with all parameters for that function.
_create (line 1034)

Creates an image of the given size.

If possible the function returns a true color image.

  • return: Error The image handler or a PEAR_Error on error.
resource|object PEAR &_create (integer $width, integer $height)
  • integer $width: The image width.
  • integer $height: The image height.
_grayscalePixel (line 1019)
  • TODO:
void _grayscalePixel ( $OriginalPixel)
  • $OriginalPixel
_grayscaleValue (line 1012)
  • TODO:
void _grayscaleValue ( $r,  $g,  $b)
  • $r
  • $g
  • $b

Inherited Methods

Inherited From Horde_Image

 Horde_Image::Horde_Image()
 Horde_Image::addEffect()
 Horde_Image::addObserver()
 Horde_Image::applyEffects()
 Horde_Image::brightness()
 Horde_Image::brush()
 Horde_Image::display()
 Horde_Image::factory()
 Horde_Image::getCapabilities()
 Horde_Image::getDimensions()
 Horde_Image::getHexColor()
 Horde_Image::getLink()
 Horde_Image::getLoadedEffects()
 Horde_Image::getRGB()
 Horde_Image::hasCapability()
 Horde_Image::headers()
 Horde_Image::loadFile()
 Horde_Image::loadString()
 Horde_Image::modifyColor()
 Horde_Image::moreIntenseColor()
 Horde_Image::notifyObservers()
 Horde_Image::raw()
 Horde_Image::reset()
 Horde_Image::singleton()
 Horde_Image::toFile()

Documentation generated on Sun, 30 Jan 2011 05:17:46 +0000 by phpDocumentor 1.4.3