Friday, June 12, 2026
HomeLanguagesPHP | ImagickDraw ellipse() Function

PHP | ImagickDraw ellipse() Function

The ImagickDraw::ellipse() function is an inbuilt function in PHP which is used to draw an ellipse on the image.

Syntax:

bool ImagickDraw::ellipse( float $ox, float $oy, 
float $rx, float $ry, float $start, float $end )

Parameters: This function accepts six parameters as mentioned above and described below:

  • $ox: It specifies the x-coordinate of the ellipse.
  • $oy: It specifies the y-coordinate of the ellipse.
  • $rx: It specifies the x-radius of the ellipse.
  • $ry: It specifies the y-radius of the ellipse.
  • $start: It specifies the start point of the ellipse.
  • $end: It specifies the end point of the ellipse.

Return Value: This function returns TRUE on success.

Exceptions: This function throws ImagickException on error.

Below given programs illustrate the ImagickDraw::ellipse() function in PHP:

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, 'purple');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Draw a ellipse
$draw->ellipse(125, 70, 100, 50, 0, 360);
  
// Render the draw commands
$imagick->drawImage($draw);
  
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>


Output:

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick();
  
// Create a image on imagick object
$imagick->newImage(800, 250, 'brown');
  
// Create a new ImagickDraw object
$draw = new ImagickDraw();
  
// Draw a black ellipse
$draw->ellipse(400, 120, 200, 100, 0, 360);
  
// Set the FillColor to green
$draw->setFillColor('green');
  
// Draw a green ellipse
$draw->ellipse(400, 120, 150, 90, 0, 360);
  
// Render the draw commands
$imagick->drawImage($draw);
  
// Show the output
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>


Output:

Reference: https://www.php.net/manual/en/imagickdraw.ellipse.php

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS