Image_Text
[ class tree: Image_Text ] [ index: Image_Text ] [ all elements ]

Class: Image_Text

Source Location: /Image_Text-0.7.0/Image/Text.php

Class Overview


Image_Text - Advanced text manipulations in images.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 1997-2005 The PHP Group

Methods


Inherited Variables

Inherited Methods


Class Details

[line 39]
Image_Text - Advanced text manipulations in images.

Image_Text provides advanced text manipulation facilities for GD2 image generation with PHP. Simply add text clippings to your images, let the class automatically determine lines, rotate text boxes around their center or top left corner. These are only a couple of features Image_Text provides.



[ Top ]


Method Detail

__construct (Constructor)   [line 298]

Image_Text __construct( string $text, [array $options = null])

Constructor

Set the text and options. This initializes a new Image_Text object. You must set your text here. Optionally you can set all options here using the $options parameter. If you finished switching all options you have to call the init() method first before doing anything further! See Image_Text::set() for further information.


Parameters:

string   $text     Text to print.
array   $options     Options.

[ Top ]

autoMeasurize   [line 628]

int autoMeasurize( [int|bool $start = false], [int|bool $end = false])

Auto measurize text

Automatically determines the greatest possible font size to fit the text into the text box. This method may be very resource intensive on your webserver. A good tweaking point are the $start and $end parameters, which specify the range of font sizes to search through. Anyway, the results should be cached if possible. You can optionally set $start and $end here as a parameter or the settings of the options array are used.

  • Return: Fontsize measured
  • See: Image_Text::measurize()
  • Todo: Beware of initialize
  • Throws: Image_Text_Exception
  • Access: public

Parameters:

int|bool   $start     Fontsize to start testing with.
int|bool   $end     Fontsize to end testing with.

[ Top ]

construct   [line 318]

Image_Text construct( string $text, array $options)

Construct and initialize an Image_Text in one step.

This method is called statically and creates plus initializes an Image_Text object. Beware: You will have to recall init() if you set an option afterwards manually.


Parameters:

string   $text     Text to print.
array   $options     Options.

[ Top ]

convertString2RGB   [line 1139]

bool|array convertString2RGB( string $scolor)

Convert a color to an array.

The following colors syntax must be used: "#08ffff00" hexadecimal format with alpha channel (08)


Parameters:

string   $scolor     string of colorcode.

[ Top ]

display   [line 990]

bool display( [bool $save = false], [bool $free = false])

Display the image (send it to the browser).

This will output the image to the users browser. You can use the standard IMAGETYPE_* constants to determine which image type will be generated. Optionally you can save your image to a destination you set in the options.

  • Return: True on success
  • See: Image_Text::save()
  • Throws: Image_Text_Exception
  • Access: public

Parameters:

bool   $save     Save or not the image on printout.
bool   $free     Free the image on exit.

[ Top ]

getImg   [line 971]

resource getImg( )

Return the image ressource.

Get the image canvas.

  • Return: Used image resource
  • Access: public

[ Top ]

init   [line 487]

void init( )

Initialize the Image_Text object.

This method has to be called after setting the options for your Image_Text object. It initializes the canvas, normalizes some data and checks important options. Be sure to check the initialization after you switched some options. The set() method may force you to reinitialize the object.


[ Top ]

measurize   [line 673]

array measurize( [bool $force = false])

Measurize text into the text box

This method makes your text fit into the defined textbox by measurizing the lines for your given font-size. You can do this manually before rendering (or use even Image_Text::autoMeasurize()) or the renderer will do measurizing automatically.


Parameters:

bool   $force     Optionally, default is false, set true to force measurizing.

[ Top ]

render   [line 841]

void render( [bool $force = false])

Render the text in the canvas using the given options.

This renders the measurized text or automatically measures it first. The $force parameter can be used to switch of measurizing problems (this may cause your text being rendered outside a given text box or destroy your image completely).

  • Throws: Image_Text_Exception
  • Access: public

Parameters:

bool   $force     Optional, initially false, set true to silence measurize errors.

[ Top ]

save   [line 1042]

void save( [bool|string $destFile = false])

Save image canvas.

Saves the image to a given destination. You can leave out the destination file path, if you have the option for that set correctly. Saving is possible with the display() method, too.


Parameters:

bool|string   $destFile     The destination to save to (optional, uses options value else).

[ Top ]

set   [line 339]

void set( array|string $option, [mixed $value = null])

Set options

Set a single or multiple options. It may happen that you have to reinitialize the Image_Text object after changing options. For possible options, please take a look at the class options array!

  • See: Image_Text::Image_Text()
  • Throws: Image_Text_Exception setting the value failed
  • Access: public

Parameters:

array|string   $option     A single option name or the options array.
mixed   $value     Option value if $option is string.

[ Top ]

setColor   [line 427]

void setColor( array|string $color, [int $id = 0])

Set a color

This method is used to set a color at a specific color ID inside the color cycle.

The following colors syntaxes are understood by this method:

  • "#ffff00" hexadecimal format (HTML style), with and without #.
  • "#08ffff00" hexadecimal format (HTML style) with alpha channel (08), with and without #.
  • array with 'r','g','b' and (optionally) 'a' keys, using int values.


Parameters:

array|string   $color     Color value.
int   $id     ID (in the color array) to set color to.

[ Top ]

setColors   [line 393]

void setColors( array|string $colors)

Set the color-set

Using this method you can set multiple colors for your text. Use a simple numeric array to determine their order and give it to this function. Multiple colors will be cycled by the options specified 'color_mode' option. The given array will overwrite the existing color settings!

The following colors syntaxes are understood by this method:

  • "#ffff00" hexadecimal format (HTML style), with and without #.
  • "#08ffff00" hexadecimal format (HTML style) with alpha channel (08), with and without #.
  • array with 'r','g','b' and (optionally) 'a' keys, using int values.
A single color or an array of colors are allowed here.


Parameters:

array|string   $colors     Single color or array of colors.

[ Top ]


Documentation generated on Wed, 07 Aug 2013 13:00:04 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.