Saturday, September 21, 2024
Google search engine
HomeLanguagesPython PIL | ImagePath.Path.getbbox() method

Python PIL | ImagePath.Path.getbbox() method

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)




   
  
# importing image class from PIL package
import math
from PIL import ImagePath
  
# creating a list to getbox 
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.




   
  
# importing image class from PIL package
import math
from PIL import ImagePath
  
# creating a list to getbox 
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)]

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

Most Popular

Recent Comments