diff --git a/reference/imagick/examples.xml b/reference/imagick/examples.xml index 5b2650a386..f98255dbfc 100644 --- a/reference/imagick/examples.xml +++ b/reference/imagick/examples.xml @@ -209,6 +209,64 @@ $im->writeImages("example_small.gif", true); + + Working with ellipse primitive and custom fonts + + Create a PHP logo + +newImage($width, $height, new ImagickPixel('transparent')); + +/* New ImagickDraw instance for ellipse draw */ +$draw = new ImagickDraw(); +/* Set purple fill color for ellipse */ +$draw->setFillColor('#777bb4'); +/* Set ellipse dimensions */ +$draw->ellipse($width / 2, $height / 2, $width / 2, $height / 2, 0, 360); +/* Draw ellipse onto the canvas */ +$img->drawImage($draw); + +/* Reset fill color from purple to black for text (note: we are reusing ImagickDraw object) */ +$draw->setFillColor('black'); +/* Set stroke border to white color */ +$draw->setStrokeColor('white'); +/* Set stroke border thickness */ +$draw->setStrokeWidth(2); +/* Set font kerning (negative value means that letters are closer to each other) */ +$draw->setTextKerning(-8); +/* Set font and font size used in PHP logo */ +$draw->setFont('Handel Gothic.ttf'); +$draw->setFontSize(150); +/* Center text horizontally and vertically */ +$draw->setGravity(Imagick::GRAVITY_CENTER); + +/* Add center "php" with Y offset of -10 to canvas (inside ellipse) */ +$img->annotateImage($draw, 0, -10, 0, 'php'); +$img->setImageFormat('png'); + +/* Set appropriate header for PNG and output the image */ +header('Content-Type: image/png'); +echo $img; +?> + +]]> + + &example.outputs.similar; + + Output of example : Creating PHP logo with Imagick + + + + + +