1--TEST-- 2Test ImagickDraw, getOpacity 3--SKIPIF-- 4<?php 5require_once(dirname(__FILE__) . '/skipif.inc'); 6checkClassMethods('ImagickDraw', array('setOpacity')); 7requirePHP("5.5.0"); 8?> 9 10--FILE-- 11<?php 12 13$backgroundColor = 'rgb(225, 225, 225)'; 14$strokeColor = 'rgb(0, 0, 0)'; 15$fillColor = 'DodgerBlue2'; 16 17 18 19$draw = new \ImagickDraw(); 20 21$draw->setStrokeColor($strokeColor); 22$draw->setFillColor($fillColor); 23 24$draw->setStrokeWidth(2); 25$draw->setFontSize(72); 26 27$opacityToSet = 0.1; 28 29$draw->setOpacity($opacityToSet); 30$opacity = $draw->getOpacity(); 31 32$delta = abs($opacity - $opacityToSet); 33if ($delta > 0.0001) { 34 echo "Failed to get correct opacity, it should be $opacityToSet but got $opacity, which is a delta of $delta\n"; 35} 36 37$draw->line(125, 70, 100, 50); 38$draw->line(350, 170, 100, 150); 39 40$imagick = new \Imagick(); 41$imagick->newImage(500, 500, $backgroundColor); 42$imagick->setImageFormat("png"); 43$imagick->drawImage($draw); 44 45 46 47 48$bytes = $imagick->getImageBlob(); 49if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 50 51 52 53echo "Ok"; 54?> 55--EXPECTF-- 56Ok