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.
Imagick::annotateImage
(PECL imagick 2.0.0)
Imagick::annotateImage — Annote une image avec un texte
Description
bool Imagick::annotateImage
( ImagickDraw $draw_settings
, float $x
, float $y
, float $angle
, string $text
)
Avertissement
Cette fonction n'est pas documentée et seule la liste des arguments est disponible.
Annote une image avec un texte.
Liste de paramètres
- draw_settings
-
L'objet ImagickDraw qui contient les directives pour dessiner le texte
- x
-
La position horizontale du texte, en pixel depuis la gauche du texte
- y
-
La position verticale du texte, en pixel depuis la ligne de base du texte
- angle
-
L'angle auquel écrire le texte
- text
-
La chaîne à dessiner
Valeurs de retour
Returns TRUE on success.
Exemples
Exemple #1 Exemple avec Imagick::annotateImage()
Annote un texte dans une image vide
<?php
/* Création de quelques objets */
$image = new Imagick();
$draw = new ImagickDraw();
$pixel = new ImagickPixel( 'gray' );
/* Nouvelle image */
$image->newImage(800, 75, $pixel);
/* Texte noir */
$pixel->setColor('black');
/* Propriétées du texte */
$draw->setFont('Bookman-DemiItalic');
$draw->setFontSize( 30 );
/* Création du texte */
$image->annotateImage($draw, 10, 45, 0, 'The quick brown fox jumps over the lazy dog');
/* Format de l'image */
$image->setImageFormat('png');
/* Affichage de l'image avec les entêtes */
header('Content-type: image/png');
echo $image;
?>
Voir aussi
- ImagickDraw::annotation() - Dessine un texte sur une image
- ImagickDraw::setFont() - Configure la police complète pour les textes
Imagick::annotateImage
alan at ridersite dot org
23-Aug-2007 07:37
23-Aug-2007 07:37
