Can ImageMagick Convert Draw Circles or Ellipses?

Yes, the ImageMagick convert command (or the magick command in newer versions) can easily draw circles and ellipses onto an existing image using the -draw operator. This capability is highly useful for automated image processing, such as highlighting specific areas of a photo, creating custom avatars, or generating geometric overlays. By leveraging coordinates and radius values, you can precisely control the placement, size, border width, and color of the shapes you render onto your base image.


How to Draw a Circle

To draw a circle on an existing image, you use the -draw option followed by the circle primitive. The circle primitive requires two sets of coordinates: the center point $(x_0, y_0)$ and a point on the perimeter $(x_1, y_1)$. ImageMagick automatically calculates the radius based on the distance between these two points.

Here is the basic syntax:

magick input.jpg -fill None -stroke red -strokewidth 3 -draw "circle 150,150 150,200" output.jpg

In this example:


How to Draw an Ellipse

If you need a squished or elongated shape rather than a perfect circle, you can use the ellipse primitive. Unlike the circle primitive, the ellipse primitive requires the center point, the x and y radii, and the starting and ending degrees of the arc (which allows you to draw partial ellipses or full 360-degree shapes).

Here is the basic syntax for a full ellipse:

magick input.jpg -fill yellow -stroke black -strokewidth 2 -draw "ellipse 200,150 80,40 0,360" output.jpg

Breaking down the ellipse parameters:


Best Practices and Tips

When drawing shapes in ImageMagick, keep these quick tips in mind for the best results: