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.pieslice() Same as arc, but also draws straight lines between the end points and the center of the bounding box.
Syntax: PIL.ImageDraw.Draw.pieslice(xy, start, end, fill=None, outline=None)
Parameters:
xy – Four points to define the bounding box. Sequence of [(x0, y0), (x1, y1)] or [x0, y0, x1, y1].
start – Starting angle, in degrees. Angles are measured from 3 o’clock, increasing clockwise.
end – Ending angle, in degrees.
fill – Color to use for the fill.
outline – Color to use for the outline.Returns: An Image object in pieslice shape.
# importing image object from PIL import math from PIL import Image, ImageDraw w, h = 220, 190shape = [(40, 40), (w - 10, h - 10)] # creating new Image object img = Image.new("RGB", (w, h)) # create pieslice image img1 = ImageDraw.Draw(img) img1.pieslice(shape, start = 50, end = 250, 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, 190shape = [(40, 40), (w - 10, h - 10)] # creating new Image object img = Image.new("RGB", (w, h)) # create pieslice image img1 = ImageDraw.Draw(img) img1.pieslice(shape, start = 50, end = 250, fill ="# 800080", outline ="white") img.show() |
Output:

Recommended Posts:
- Python PIL | GaussianBlur() method
- Python PIL | Kernel() method
- Python PIL | BoxBlur() method
- Python PIL | getbands() method
- Python PIL | logical_and() and logical_or() method
- Python PIL | ImageChops.subtract() method
- Python PIL | UnsahrpMask() method
- Python PIL | ImageChops.subtract() and ImageChops.subtract_modulo() method
- Python PIL | Image.crop() method
- Python PIL | ImageOps.expand() method
- Python PIL | ImageEnhance.Color() and ImageEnhance.Contrast() method
- Python PIL | ImageGrab.grabclipboard() method
- Python PIL | RankFilter() method
- Python PIL | ImageChops.screen() and ImageChops.offset() method
- Python PIL | MedianFilter() and ModeFilter() method
- Python PIL | Image.new() method
- Python PIL | getbands() and getextrema() method
- Python PIL | paste() and rotate() method
- Python PIL | ImageChops.darker() method
- Python PIL | Image.split() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

