phpDocumentor Swift
[ class tree: Swift ] [ index: Swift ] [ all elements ]

Class: SwiftImage

Source Location: /classes/SwiftImage.php

Class SwiftImage

Class Overview

The SwiftImage class contains functions to help us create and write text onto images dynamically. (Note: This class requires the GB Library).

Located in /classes/SwiftImage.php [line 42]



		
		
		
		

Methods

[ Top ]
Method Summary
SwiftImage   __construct()   Creates a new SwiftImage object.
Boolean   drawBackground()   Draws background with the given properties onto the image.
Boolean   drawEllipse()   Draws a ellipse with the given properties onto the image.
Boolean   drawFilledEllipse()   Draws a filled ellipse with the given properties onto the image.
Boolean   drawFilledRectangle()   Draws a filled rectangle with the given properties onto the image.
Boolean   drawGrid()   Draws a grid of lines with the given properties onto the image.
Boolean   drawLine()   Draws a line with the given properties onto the image.
Boolean   drawRectangle()   Draws a rectangle with the given properties onto the image.
Boolean   drawSwiftImage()   Draws a SwiftImage object onto the current SwiftImage object.
Boolean   drawText()   Draws text with the given properties onto the image.
Integer   getHeight()   Returns the height in pixels of the current image resource.
Resource   getResource()   Returns the GD image resource.
Integer   getTextHeight()   Returns the height in pixels of the provided text and attributes.
Integer   getTextWidth()   Returns the width in pixels of the provided text and attributes.
Integer   getWidth()   Returns the width in pixels of the current image resource.
Boolean   renderGif()   Render and output the image as a GIF file.
Boolean   renderJpeg()   Render and output the image as a JPEG file.
Boolean   renderPng()   Render and output the image as a PNG file.
Boolean   setTransparentColor()   Sets the given color as transparent on the image pallette.

[ Top ]
Methods
Constructor __construct  [line 54]

  SwiftImage __construct( [String $filename = null], Integer $width, Integer $height  )

Creates a new SwiftImage object.

Parameters:
String   $filename:  The filename of a PNG, GIF, or JPEG image to load. (Optional)
Integer   $width:  The width of the image to render. (Specifiy if $filename is not provided)
Integer   $height:  The height of the image to render. (Specifiy if $filename is not provided)

API Tags:
Return:  The new SwiftImage object.
Access:  public


[ Top ]
drawBackground  [line 255]

  Boolean drawBackground( [Array $color = array('red' => '255', 'green' => '255', 'blue' => '255', 'alpha' => '0')]  )

Draws background with the given properties onto the image.

Parameters:
Array   $color:  An array containing color values from 0 to 255 for the keys: 'red', 'green', 'blue', and 'alpha'.

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
drawEllipse  [line 321]

  Boolean drawEllipse( Integer $x, Integer $y, Integer $width, Integer $height, [Array $color = array('red' => '0', 'green' => '0', 'blue' => '0', 'alpha' => '0')], [Integer $thickness = 1]  )

Draws a ellipse with the given properties onto the image.

Parameters:
Integer   $x:  The x coordinate of the center of the ellipse.
Integer   $y:  The y coordinate of the center of the ellipse.
Integer   $width:  The width in pixels of the ellipse.
Integer   $height:  The height in pixels of the ellipse.
Array   $color:  An array containing color values from 0 to 255 for the keys: 'red', 'green', 'blue', and 'alpha'.
Integer   $thickness:  Sets the line thickness when drawing onto image. (Default: 1)

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
drawFilledEllipse  [line 304]

  Boolean drawFilledEllipse( Integer $x, Integer $y, Integer $width, Integer $height, [Array $color = array('red' => '0', 'green' => '0', 'blue' => '0', 'alpha' => '0')]  )

Draws a filled ellipse with the given properties onto the image.

Parameters:
Integer   $x:  The x coordinate of the center of the ellipse.
Integer   $y:  The y coordinate of the center of the ellipse.
Integer   $width:  The width in pixels of the ellipse.
Integer   $height:  The height in pixels of the ellipse.
Array   $color:  An array containing color values from 0 to 255 for the keys: 'red', 'green', 'blue', and 'alpha'.

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
drawFilledRectangle  [line 269]

  Boolean drawFilledRectangle( Integer $x1, Integer $y1, Integer $x2, Integer $y2, [Array $color = array('red' => '0', 'green' => '0', 'blue' => '0', 'alpha' => '0')]  )

Draws a filled rectangle with the given properties onto the image.

Parameters:
Integer   $x1:  The x coordinate of the upper left point of the rectangle.
Integer   $y1:  The y coordinate of the upper left point of the rectangle.
Integer   $x2:  The x coordinate of the lower right point of the rectangle.
Integer   $y2:  The y coordinate of the lower right point of the rectangle.
Array   $color:  An array containing color values from 0 to 255 for the keys: 'red', 'green', 'blue', and 'alpha'.

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
drawGrid  [line 358]

  Boolean drawGrid( Integer $x_spacing, Integer $y_spacing, [Array $color = array('red' => '0', 'green' => '0', 'blue' => '0', 'alpha' => '0')], [Integer $thickness = 1], [Integer $offset = 0]  )

Draws a grid of lines with the given properties onto the image.

Parameters:
Integer   $x_spacing:  Number of pixels to space between vertical lines of grid.
Integer   $y_spacing:  Number of pixels to space between horizontal lines of grid.
Array   $color:  An array containing color values from 0 to 255 for the keys: 'red', 'green', 'blue', and 'alpha'.
Integer   $thickness:  Sets the line thickness when drawing onto image. (Default: 1)
Integer   $offset:  Value to offset the angle of the grid lines.

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
drawLine  [line 340]

  Boolean drawLine( Integer $x1, Integer $y1, Integer $x2, Integer $y2, [Array $color = array('red' => '0', 'green' => '0', 'blue' => '0', 'alpha' => '0')], [Integer $thickness = 1]  )

Draws a line with the given properties onto the image.

Parameters:
Integer   $x1:  The x coordinate of the starting point of the line.
Integer   $y1:  The y coordinate of the starting point of the line.
Integer   $x2:  The x coordinate of the ending point of the line.
Integer   $y2:  The y coordinate of the ending point of the line.
Array   $color:  An array containing color values from 0 to 255 for the keys: 'red', 'green', 'blue', and 'alpha'.
Integer   $thickness:  Sets the line thickness when drawing onto image. (Default: 1)

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
drawRectangle  [line 286]

  Boolean drawRectangle( Integer $x1, Integer $y1, Integer $x2, Integer $y2, [Array $color = array('red' => '0', 'green' => '0', 'blue' => '0', 'alpha' => '0')], [Integer $thickness = 1]  )

Draws a rectangle with the given properties onto the image.

Parameters:
Integer   $x1:  The x coordinate of the upper left point of the rectangle.
Integer   $y1:  The y coordinate of the upper left point of the rectangle.
Integer   $x2:  The x coordinate of the lower right point of the rectangle.
Integer   $y2:  The y coordinate of the lower right point of the rectangle.
Array   $color:  An array containing color values from 0 to 255 for the keys: 'red', 'green', 'blue', and 'alpha'.
Integer   $thickness:  Sets the line thickness when drawing onto image. (Default: 1)

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
drawSwiftImage  [line 238]

  Boolean drawSwiftImage( SwiftImage $swift_image, Integer $dest_x, Integer $dest_y, [Integer $src_width = null], [Integer $src_height = null], [Integer $alpha_pct = 100]  )

Draws a SwiftImage object onto the current SwiftImage object.

Parameters:
SwiftImage   $swift_image:  A SwiftImage object to copy onto the current SwiftImage.
Integer   $dest_x:  The x-coordinate value to draw at.
Integer   $dest_y:  The y-coordinate value to draw at.
Integer   $src_width:  The width in pixels to retrieve of the source.
Integer   $src_height:  The width in pixels to retrieve of the source.
Integer   $alpha_pct:  The alpha percentage of image between 0 and 100. (0 = Transparent, 100 = Opaque)

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
drawText  [line 157]

  Boolean drawText( String $text, Integer $size, [Array $color = array('red' => '0', 'green' => '0', 'blue' => '0', 'alpha' => '0')], [String $font = 'arial'], [Mixed $position = 'center'], [Integer $x_padding = 10], [Integer $y_padding = 10], [Integer $angle = 0]  )

Draws text with the given properties onto the image.

Parameters:
String   $text:  The text to write onto the image.
Integer   $size:  The size of the text.
Array   $color:  An array containing color values from 0 to 255 for the keys: 'red', 'green', 'blue', and 'alpha'.
Mixed   $position:  Sets the position of the text on the image. Use String value to specify relative position: center, top, bottom, left, right, topleft, bottomleft, topright, bottomright. Otherwise, provide Array with X and Y keys describing coordinates.
String   $font:  Sets the font type. (arial, comicsans, couriernew, georgia, tahoma, timesnewroman, verdana)
Integer   $x_padding:  Sets the x coordinate padding when positioning the text. (Default: 10)
Integer   $y_padding:  Sets the Y coordinate padding when positioning the text. (Default: 10)
Integer   $angle:  Sets the angle in degrees to draw the text at.

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
getHeight  [line 89]

  Integer getHeight( )

Returns the height in pixels of the current image resource.


API Tags:
Return:  The pixel height of the image.
Access:  public


[ Top ]
getResource  [line 73]

  Resource getResource( )

Returns the GD image resource.


API Tags:
Return:  The image resource.
Access:  public


[ Top ]
getTextHeight  [line 121]

  Integer getTextHeight( String $text, Integer $size, [Integer $angle = 0], [String $font = 'arial']  )

Returns the height in pixels of the provided text and attributes.

Parameters:
String   $text:  The text to find the height for.
Integer   $size:  The size of the font.
Integer   $angle:  The angle of the text. (Default: 0)
String   $font:  The name of the font. (Default: arial)

API Tags:
Return:  The pixel height of the text.
Access:  public


[ Top ]
getTextWidth  [line 101]

  Integer getTextWidth( String $text, Integer $size, [Integer $angle = 0], [String $font = 'arial']  )

Returns the width in pixels of the provided text and attributes.

Parameters:
String   $text:  The text to find the width for.
Integer   $size:  The size of the font.
Integer   $angle:  The angle of the text. (Default: 0)
String   $font:  The name of the font. (Default: arial)

API Tags:
Return:  The pixel width of the text.
Access:  public


[ Top ]
getWidth  [line 81]

  Integer getWidth( )

Returns the width in pixels of the current image resource.


API Tags:
Return:  The pixel width of the image.
Access:  public


[ Top ]
renderGif  [line 393]

  Boolean renderGif( )

Render and output the image as a GIF file.


API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
renderJpeg  [line 384]

  Boolean renderJpeg( [Integer $quality = 100]  )

Render and output the image as a JPEG file.

Parameters:
Integer   $quality:  A value between 0 (lowest) and 100 (highest) for quality of image.

API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
renderPng  [line 374]

  Boolean renderPng( )

Render and output the image as a PNG file.


API Tags:
Return:  True on success, otherwise False.
Access:  public


[ Top ]
setTransparentColor  [line 138]

  Boolean setTransparentColor( [Array $color = array('red' => '0', 'green' => '0', 'blue' => '0')]  )

Sets the given color as transparent on the image pallette.

Parameters:
Array   $color:  An array containing color values from 0 to 255 for the keys: 'red', 'green', and 'blue'.

API Tags:
Return:  True on success, otherwise False.


[ Top ]

Documentation generated on Tue, 08 Oct 2013 05:37:16 +0200 by phpDocumentor 1.4.4