Saturday, September 6, 2025
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
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32270 POSTS0 COMMENTS
Milvus
82 POSTS0 COMMENTS
Nango Kala
6639 POSTS0 COMMENTS
Nicole Veronica
11803 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11869 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7029 POSTS0 COMMENTS
Thapelo Manthata
6704 POSTS0 COMMENTS
Umr Jansen
6721 POSTS0 COMMENTS