downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Imagick::appendImages> <Imagick::animateImages
Last updated: Fri, 20 May 2011

view this page in

Imagick::annotateImage

(PECL imagick 2.0.0)

Imagick::annotateImageAnota una imagen con texto

Descripción

bool Imagick::annotateImage ( ImagickDraw $draw_settings , float $x , float $y , float $angle , string $text )

Anota una imagen con texto.

Parámetros

draw_settings

El objeto ImagickDraw que contiene la configuración para el dibujo de texto

x

El índice horizontal en píxeles a la izquierda del texto

y

El índice vertical en píxeles de la línea base del texto

angle

El ángulo en el que se escribe el texto

text

La cadena a dibujar

Valores devueltos

Devuelve TRUE en caso de éxito.

Ejemplos

Example #1 Usar Imagick::annotateImage():

Anotar texto en una imagen vacía

<?php
/* Crear algunos objetos */
$imagen = new Imagick();
$dibujo = new ImagickDraw();
$píxel = new ImagickPixel'gray' );

/* Nueva imagen */
$imagen->newImage(80075$píxel);

/* Texto negro */
$dibujo->setColor('black');

/* Propiedades de la fuente */
$dibujo->setFont('Bookman-DemiItalic');
$dibujo->setFontSize30 );

/* Crear texto */
$imagen->annotateImage($dibujo10450'The quick brown fox jumps over the lazy dog');

/* Dar a la imagen un formato */
$imagen->setImageFormat('png');

/* Imprimir la imagen con cabeceras */
header('Content-type: image/png');
echo 
$imagen;

?>

Ver también



add a note add a note User Contributed Notes Imagick::annotateImage
alan at ridersite dot org 23-Aug-2007 07:37
If ImagickDraw::setGravity ( int $gravity ) has been set, e,g; with $gravity= imagick::GRAVITY_CENTER.

Then, the x and y values offset the text from where the gravity setting would have placed it.

If the example included: $draw->setGravity (Imagick::GRAVITY_CENTER);
$image->annotateImage($draw, 10, 45, 0, 'The quick brown fox jumps over the lazy dog');

The text would be rendered to the right 10px and down 45px from the center. 

Gravity constants are very useful as they can save having to calculate the placement of variable text strings and font sizes.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites