Friday, October 3, 2025
HomeLanguagesPython PIL | ImageDraw.Draw.ellipse()

Python PIL | ImageDraw.Draw.ellipse()

PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImageDraw module provide simple 2D graphics for Image objects. You can use this module to create new images, annotate or retouch existing images, and to generate graphics on the fly for web use.

ImageDraw.Draw.ellipse() Draws an ellipse inside the given bounding box.

Syntax: PIL.ImageDraw.Draw.ellipse(xy, fill=None, outline=None)

Parameters:
xy – Four points to define the bounding box. Sequence of either [(x0, y0), (x1, y1)] or [x0, y0, x1, y1].
outline – Color to use for the outline.
fill – Color to use for the fill.

Returns: An Image object in ellipse shape.




   
  
# importing image object from PIL
import math
from PIL import Image, ImageDraw
  
w, h = 220, 190
shape = [(40, 40), (w - 10, h - 10)]
  
# creating new Image object
img = Image.new("RGB", (w, h))
  
# create ellipse image
img1 = ImageDraw.Draw(img)  
img1.ellipse(shape, fill ="# ffff33", outline ="red")
img.show()


Output:

Another Example: Here we use different colour for filling.




   
  
# importing image object from PIL
import math
from PIL import Image, ImageDraw
  
w, h = 220, 190
shape = [(40, 40), (w - 10, h - 10)]
  
# creating new Image object
img = Image.new("RGB", (w, h))
  
# create ellipse image
img1 = ImageDraw.Draw(img)  
img1.ellipse(shape, fill ="# 800080", outline ="green")
img.show()


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32331 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11868 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11929 POSTS0 COMMENTS
Shaida Kate Naidoo
6818 POSTS0 COMMENTS
Ted Musemwa
7080 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS