Horde_Image_Imagick::text PHP Method

text() public method

Draws a text string on the image in a specified location, with the specified style information.
public text ( $string, integer $x, integer $y, string $font = '', string $color = 'black', integer $direction, string $fontsize = 'small' )
$x integer The left x coordinate of the start of the text string.
$y integer The top y coordinate of the start of the text string.
$font string The font identifier you want to use for the text.
$color string The color that you want the text displayed in.
$direction integer An integer that specifies the orientation of the text.
$fontsize string Size of the font (small, medium, large, giant)
    public function text($string, $x, $y, $font = '', $color = 'black', $direction = 0, $fontsize = 'small')
    {
        $fontsize = Horde_Image::getFontSize($fontsize);
        try {
            $pixel = new ImagickPixel($color);
        } catch (ImagickPixelException $e) {
            throw new Horde_Image_Exception($e);
        }
        try {
            $draw = new ImagickDraw();
            $draw->setFillColor($pixel);
            if (!empty($font)) {
                $draw->setFont($font);
            }
            $draw->setFontSize($fontsize);
            $draw->setGravity(Imagick::GRAVITY_NORTHWEST);
        } catch (ImagickDrawException $e) {
            throw new Horde_Image_Exception($e);
        }
        try {
            $this->_imagick->annotateImage($draw, $x, $y, $direction, $string);
        } catch (ImagickException $e) {
            throw new Horde_Image_Exception($e);
        }
        $draw->destroy();
    }