1--TEST--
2Test ImagickDraw, setGravity
3--SKIPIF--
4<?php
5$imageMagickRequiredVersion=0x675;
6require_once(dirname(__FILE__) . '/skipif.inc');
7?>
8--FILE--
9<?php
10
11require_once(dirname(__FILE__) . '/functions.inc');
12
13$backgroundColor = 'rgb(225, 225, 225)';
14$strokeColor = 'rgb(0, 0, 0)';
15$fillColor = 'DodgerBlue2';
16
17function setGravity($fillColor, $strokeColor, $backgroundColor) {
18
19    $draw = new \ImagickDraw();
20    setFontForImagickDraw($draw);
21    $draw->setStrokeColor($strokeColor);
22    $draw->setFillColor($fillColor);
23    $draw->setStrokeWidth(1);
24    $draw->setFontSize(24);
25
26    $gravitySettings = array(\Imagick::GRAVITY_NORTHWEST => 'NorthWest', \Imagick::GRAVITY_NORTH => 'North', \Imagick::GRAVITY_NORTHEAST => 'NorthEast', \Imagick::GRAVITY_WEST => 'West', \Imagick::GRAVITY_CENTER => 'Centre', \Imagick::GRAVITY_SOUTHWEST => 'SouthWest', \Imagick::GRAVITY_SOUTH => 'South', \Imagick::GRAVITY_SOUTHEAST => 'SouthEast', \Imagick::GRAVITY_EAST => 'East');
27
28
29    foreach ($gravitySettings as $type => $description) {
30        $draw->setGravity($type);
31        $draw->annotation(50, 50, '"' . $description . '"');
32    }
33
34    $imagick = new \Imagick();
35    $imagick->newImage(500, 500, $backgroundColor);
36    $imagick->setImageFormat("png");
37    $imagick->drawImage($draw);
38
39    $bytes = $imagick->getImageBlob();
40    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
41}
42
43setGravity($fillColor, $strokeColor, $backgroundColor) ;
44echo "Ok";
45?>
46--EXPECTF--
47Ok