Reference Manuals

AddText

AddText — Add TTF text to an image

AddText is part of the Gallery package.

Synopsis

class AddText implements Transform {
        private        array               $color
        private        string              $font
        private        int                 $hpos
        private        float               $size
        private        string              $text
        private        int                 $vpos

        public         AddText             __construct               ( string $text,
                                                                       int $vpos,
                                                                       int $hpos,
                                                                       string $font,
                                                                       float $size,
                                                                       array $color );
        public         resource            apply                     ( resource $image,
                                                                        &$image );
}

Object Hierarchy

AddText

Implemented Interfaces

AddText implements Transform

Description

Add TTF text to an image

Attribute Details

$color

private        array          $color

An array of three elements for the color in RGB

Default value: empty string


$font

private        string         $font

Path to the TTF file. See the description on the fontile variable on http://www.php.net/manual/en/function.imagettftext.php

Default value: empty string


$hpos

private        int            $hpos

The horizontal position of the text. Must be one of WG_LEFT, WG_CENTER or WG_RIGHT

Default value: empty string


$size

private        float          $size

The size of the font in pt

Default value: empty string


$text

private        string         $text

The text to render

Default value: empty string


$vpos

private        int            $vpos

The vertical position of the text. Must be one of WG_TOP, WG_CENTER or WG_BOTTOM

Default value: empty string

Method Details

__construct()

public         AddText        __construct               ( string $text,
                                                          int $vpos,
                                                          int $hpos,
                                                          string $font,
                                                          float $size,
                                                          array $color );

Create and initialize the AddText transform

The vpos variable should be one of WG_TOP, WG_CENTER or WG_BOTTOM. The hpos variable should be one of WG_LEFT, WG_CENTER or WG_RIGHT. For the correct specification of the font attribute, see the PHP documentation on imagettftext on the fontfile variable at http://www.php.net/manual/en/function.imagettftext.php

$text
The text to render
$vpos
The vertical position of the text
$hpos
The horizontal position of the text
$font
Path to a TTF font file
$size
Size of the font in pt
$color
An array containing 3 integer elements representing the color in RGB

apply()

public         resource       apply                     ( resource $image,
                                                           &$image );

Add the text to the image

$image
&$image