1--TEST--
2Test ImagickDraw, setClipUnits
3--SKIPIF--
4<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
5--FILE--
6<?php
7
8$backgroundColor = 'rgb(225, 225, 225)';
9$strokeColor = 'rgb(0, 0, 0)';
10$fillColor = 'DodgerBlue2';
11
12function setClipUnits($strokeColor, $fillColor, $backgroundColor) {
13
14    $draw = new \ImagickDraw();
15
16    $draw->setStrokeColor($strokeColor);
17    $draw->setFillColor($fillColor);
18    $draw->setStrokeOpacity(1);
19    $draw->setStrokeWidth(2);
20    $clipPathName = 'testClipPath';
21    $draw->setClipUnits(\Imagick::RESOLUTION_PIXELSPERINCH);
22    $draw->pushClipPath($clipPathName);
23    $draw->rectangle(0, 0, 250, 250);
24    $draw->popClipPath();
25    $draw->setClipPath($clipPathName);
26
27    //RESOLUTION_PIXELSPERINCH
28    //RESOLUTION_PIXELSPERCENTIMETER
29
30    $draw->rectangle(200, 200, 300, 300);
31    $imagick = new \Imagick();
32    $imagick->newImage(500, 500, $backgroundColor);
33    $imagick->setImageFormat("png");
34
35    $imagick->drawImage($draw);
36
37    $bytes = $imagick->getImageBlob();
38    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
39}
40
41setClipUnits($strokeColor, $fillColor, $backgroundColor) ;
42echo "Ok";
43?>
44--EXPECTF--
45Ok