Drawing an Arc in Imagick

June 19th, 2009

Warning: This post is 15 years old. Some of this information may be out of date.

Here's how to draw an arc using PHP Imagick

$canvas = new Imagick();
$canvas->newImage(200, 200, new ImagickPixel("white"),'png');

$arc = new ImagickDraw();
$arc->setFillColor('red');
$arc->setStrokeColor('black');
$arc->setStrokeWidth(2);

/* x1,x2,y1,y2, start angle, end angle */
$arc->arc(30, 30, 160, 160, -70, 70);

$canvas->drawImage($arc);
$canvas->borderImage('black', 1, 1);
header('content-type: image/png');
echo $canvas->getImage();
exit();

Produces:

Drawing an arc with Imagemagick and PHP