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)

filter_none

edit
close

play_arrow

link
brightness_4
code

   
  
# 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)

chevron_right


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.

filter_none

edit
close

play_arrow

link
brightness_4
code

   
# 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)

chevron_right


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)]




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.