Python PIL | ImageDraw.Draw.ellipse ()

Python Methods and Functions

ImageDraw.Draw.ellipse() Draws an ellipse inside the specified 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.

Output:

Another example: here we use a different fill color.

 

 
# import image object from PIL

import math

from PIL import Image, ImageDraw

 

w, h = 220 , 190

shape = [( 40 , 40 ), (w - 10 , h - 10 )]

 
# create a 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 ()

 

 
# import image object from PIL

import math

from PIL import Image, ImageDraw

  

w, h = 220 , 190

shape = [( 40 , 40 ), (w - 10 , h - 10 )]

 
# create a new Image

img = Image.new ( " RGB " , (w, h))

 
# create ellipse image

img1 = ImageDraw.Draw (img) 

img1.ellipse (shape, fill = "# 800080" , outline = "green" )

img.show ()

Output:





Tutorials