Class Image_Text

Description

Image_Text A generic class for text operations on images

Located in /Image_Text.php (line 24)


	
			
Variable Summary
 resource $img
 array $lines
 array $options
 int $_current
Method Summary
 Image_Text Image_Text (string $text, array $options)
 void addBorder (int $lineWidth, mixed $fgColor, mixed $bgColor, int $spacing, int $roundWidth)
 void addShadow (mixed $xAdjust, mixed $yAdjust, [mixed $color = false])
 void align ([const $align = null])
 void colorize ([mixed $color = null], [mixed $bgcolor = null])
 int countLines ()
 array &getAllLines ()
 array getAllTokens ()
 mixed &getImage ()
 array getSize ([array $lines = null], [int $fontsize = null])
 bool measurize ()
 bool outImage ([string $imageType = null])
 void renderImage (int $x, int $y, resource &$img)
 void rotate (mixed $angle)
 void _checkImageType (mixed $imageType)
 bool _checkOptions (array $options, [mixed $initial = true])
 resource &_newImage (int $x, int $y)
 bool _prepareImage ([string $imageType = null])
 void &_testMeasure (bool &$lines, array &$tokens, string $font, int $fontsize)
Variables
resource $img (line 71)

The image generated

  • var: image
array $lines = array() (line 33)

The lines of the text

  • var: object ImageText
  • access: public
array $options = array(
'fontPath' => "./", 'fontFile' => "", 'width' => 0, 'height' => 0, 'fontSize' => 1, 'color' => array('r' => 255, 'g' => 255, 'b' => 255),'bgcolor'=>false,'minFontSize'=>1,'maxFontSize'=>100,'maxLines'=>100,'align'=>IMAGE_TEXT_ALIGN_LEFT,'borderWidth'=>0,'borderColor'=>false,'borderRoundWidth'=>0,'borderSpacing'=>0,'shadowX'=>false,'shadowY'=>false,'shadowColor'=>false,'imageType'=>'png')
(line 44)

Options array, these options can be set through the constructor, fontFile and fontPath, width and height are obligatory

  • access: public
int $_current = 0 (line 79)

Stores the current line key (in lack of array_funtions returning references

Methods
Constructor Image_Text (line 90)

Constructor Constructor

  • access: public
Image_Text Image_Text (string $text, array $options)
  • string $text: The text to render as string, array of strings or array of ImageTextLine objects
  • array $options: Array of options (see public attributes). fontPath, fontFile, width and height are neccessary
addBorder (line 307)

Add a border to your text box This method adds a border with the given settings to your text box.

The border is outlined for standard, if you want to have the border inlined, use a negative spacing value. Beware, that if you place a border inside an image, eveything under the textbox will be overwriten. If you use rounding, the border background has to have the same color as your image background.

  • access: public
void addBorder (int $lineWidth, mixed $fgColor, mixed $bgColor, int $spacing, int $roundWidth)
  • int $lineWidth: Width of the line for the border
  • int $spacing: Space between text and border
  • int $roundWidth: If you like rounded edges, set this to a positive value
  • mixed $fgColor: color $fgColor Color of the border @see Imaget_Text::colorize() for color types
  • mixed $bgColor: color $bgColor Background color of your @see Imaget_Text::colorize() for color types
addShadow (line 317)
void addShadow (mixed $xAdjust, mixed $yAdjust, [mixed $color = false])
align (line 249)

Align all lines in the textbox Align all lines in the textbox

  • access: public
void align ([const $align = null])
  • const $align: The align to set (optional, takes the own)
colorize (line 270)

Colorize the text box

Colorize the lines in the text box. This method can take 2 color formats. It either gets an array with keys "r", "g" and "b" asigned to a decimal number or a HTML style hex code triple representing the color. It is althought possible to give this method an array of the mentioned color types to alternate the color of the lines. If there are more lines than colors, the colors are cycled.

  • access: public
void colorize ([mixed $color = null], [mixed $bgcolor = null])
  • mixed $color: The color(s) to set
countLines (line 383)

Get number of lines in this object Get number of lines in this object

  • return: Number of lines
int countLines ()
currentLine (line 344)

Get the current selected line (reference) Get the current selected line (reference)

  • return: The current line as refernce
Image_Text_Line &currentLine ()
firstLine (line 371)

Get the first line and select it (reference) Get the first line and select it (reference)

  • return: The first line as refernce
Image_Text_Line &firstLine ()
getAllLines (line 395)

Get all lines Get all lines

  • return: string Array of Image_Text_Line objects
  • access: public
array &getAllLines ()
getAllTokens (line 407)

Get all tokens of your text in one array Get all tokens of your text in one array

  • return: string Array of tokens
  • access: public
array getAllTokens ()
getImage (line 178)

Return the image resource (reference) Return the image resource (reference)

  • return: Resource image on success, otherwise false
mixed &getImage ()
getSize (line 195)

Get the size of the text box Get the size of the text box

  • return: The size of the box
  • access: public
array getSize ([array $lines = null], [int $fontsize = null])
  • array $lines: The lines in the text box (optional, takes the owned lines)
  • int $fontsize: The font size to check with (optional, takes the own)
measurize (line 220)

Measure the text in the box This function trys to find out the best measures for a given text. It determines the optimal font size and the lines and their content in the box.

  • return: True on success, otherwise false
  • access: public
bool measurize ()
nextLine (line 355)

Get the next line and select it (reference) Get the next line and select it (reference)

  • return: The next line as refernce
Image_Text_Line &nextLine ()
outImage (line 161)

Output image to stdout (normaly browser) Output image to stdout (normaly browser)

  • return: True on success, otherwise failure
bool outImage ([string $imageType = null])
  • string $imageType: a valig image-type (optional)
renderImage (line 119)

Render the text to an image Render the text to an image

  • access: public
void renderImage (int $x, int $y, resource &$img)
  • int $x: The x position of the text box
  • int $y: The y position of the text box
  • resource &$img: image $img The image to render to (optional, give false to create new)
rotate (line 327)

NOT CORRECT IMPLEMENTED YET!!!

void rotate (mixed $angle)
_checkImageType (line 480)
void _checkImageType (mixed $imageType)
_checkOptions (line 423)

Check the options array Check the options array

  • return: True on success, otherwise failure
bool _checkOptions (array $options, [mixed $initial = true])
  • array $options: The array of options
_newImage (line 448)

Create a new image Create a new image

  • return: image The new image resource
resource &_newImage (int $x, int $y)
  • int $x: The x adjustment of the text box
  • int $y: The y adjustment of the text box
_prepareImage (line 464)

Prepare the image for output Prepare the image for output

  • return: True on succes, otherwise failure
bool _prepareImage ([string $imageType = null])
  • string $imageType: The type of image (see options, optional)
_testMeasure (line 548)

The actual measurizer process The actual measurizer process, called recursively for a special font and font size from attribute maxFontSize until it finds a fitting solution or attribute minFontSize is reached.

  • todo: This could be optimized I think for performance and line division issues.
void &_testMeasure (bool &$lines, array &$tokens, string $font, int $fontsize)
  • bool $lines: Has to be false (becomes the new lines array while recursing, has to be a reverence)
  • array $tokens: All current text tokens (copy of the actual but a reverence, because recursion)
  • string $font: The complete fontpath + file
  • int $fontsize: The fontsize to test with

Documentation generated on Sat, 11 Oct 2003 18:01:56 +0200 by phpDocumentor 1.2.2