Python PIL | ImagePath.Path.getbbox() method
Last Updated :
02 Aug, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImagePath
module is used to store and manipulate 2-dimensional vector data. Path objects can be passed to the methods on the ImageDraw
module.
ImagePath.Path.getbbox()
Gets the bounding box of the path.
Syntax: ImagePath.Path.getbbox()
Parameters:
arguments-creating a getbox list.
range– assigning a range.
Returns: (x0, y0, x1, y1)
import math
from PIL import ImagePath
getbox = list ( zip ( range ( 2 , 51 , 5 ), range ( 14 , 25 , 5 )))
result = ImagePath.Path(getbox).getbbox()
print (result)
print (getbox)
|
Output:
(2.0, 14.0, 12.0, 24.0)
[(2, 14), (7, 19), (12, 24)]
Another Example: changing parameters.
import math
from PIL import ImagePath
getbox = list ( zip ( range ( 3 , 41 , 1 ), range ( 11 , 22 , 2 )))
result = ImagePath.Path(getbox).getbbox()
print (result)
print (getbox)
|
Output:
(3.0, 11.0, 8.0, 21.0)
[(3, 11), (4, 13), (5, 15), (6, 17), (7, 19), (8, 21)]
Share your thoughts in the comments
Please Login to comment...