mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Added new imagick basic usage example provided by Dejan Marjanovic dejan.marjanovic@gmail.com.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328792 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
e372ce97f9
commit
5c79820b1b
1 changed files with 58 additions and 0 deletions
|
@ -209,6 +209,64 @@ $im->writeImages("example_small.gif", true);
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
Working with ellipse primitive and custom fonts
|
||||
<example>
|
||||
<title>Create a PHP logo</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* Set width and height in proportion of genuine PHP logo */
|
||||
$width = 400;
|
||||
$height = 210;
|
||||
|
||||
/* Create an Imagick object with transparent canvas */
|
||||
$img = new Imagick();
|
||||
$img->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;
|
||||
?>
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<mediaobject>
|
||||
<alt>Output of example : Creating PHP logo with Imagick</alt>
|
||||
<imageobject>
|
||||
<imagedata fileref="en/reference/imagick/figures/php_logo.png"/>
|
||||
</imageobject>
|
||||
</mediaobject>
|
||||
</example>
|
||||
</para>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
|
|
Loading…
Reference in a new issue