Saturday, December 28, 2024
Google search engine
HomeLanguagesPython PIL | ImagePath.Path.map() method

Python PIL | ImagePath.Path.map() 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.map() maps the path through the function.

Syntax: ImagePath.Path.map(function)

Parameters:
arguments-creating a list.
range– assigning a range.

Returns: (x0, y0)




   
  
# from PIL importing ImagePath
from PIL import ImagePath
  
# creating a list to map
getbox = list(zip(range(3, 41, 1), range(11, 22, 2)))
result = ImagePath.Path(getbox)
  
# using map function
b = result.map(lambda x, y: (x + 2, y + 2))
a = result.tolist()
print(a)


Output:

[(5.0, 13.0), (6.0, 15.0), (7.0, 17.0), (8.0, 19.0), (9.0, 21.0), (10.0, 23.0)]

Another Example: changing parameters.




   
# from PIL importing ImagePath
from PIL import ImagePath
  
# creating a list to map
getbox = list(zip(range(3, 41, 1), range(11, 22, 2)))
result = ImagePath.Path(getbox)
  
# using map function
b = result.map(lambda x, y: (x + 12, y + 12))
a = result.tolist()
print(a)


Output:

[(15.0, 23.0), (16.0, 25.0), (17.0, 27.0), (18.0, 29.0), (19.0, 31.0), (20.0, 33.0)]

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