Saturday, November 22, 2025
HomeLanguagesPython PIL | ImagePath.Path.tolist() method

Python PIL | ImagePath.Path.tolist() 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.tolist() Converts the path to a Python list [(x, y), …].

Syntax: PIL.ImagePath.Path.tolist(flat=0)

Parameters:

flat – By default, this function returns a list of 2-tuples [(x, y), …]. If this argument is True, it returns a flat list [x, y, …] instead.

Returns: A list of coordinates.




   
  
# 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 tolist function
a = result.tolist()
print(getbox)
print(a)


Output:

[(3, 11), (4, 13), (5, 15), (6, 17), (7, 19), (8, 21)]
[(3.0, 11.0), (4.0, 13.0), (5.0, 15.0), (6.0, 17.0), (7.0, 19.0), (8.0, 21.0)]

Another Example: changing parameters.




   
  
# from PIL importing ImagePath
from PIL import ImagePath
  
# creating a list to map
getbox = list(zip(range(5, 51, 16), range(15, 22, 4)))
result = ImagePath.Path(getbox)
  
# using tolist function
a = result.tolist()
print(getbox)
print(a)


Output:

[(5, 15), (21, 19)]
[(5.0, 15.0), (21.0, 19.0)]

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

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6784 POSTS0 COMMENTS
Nicole Veronica
11931 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11999 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6863 POSTS0 COMMENTS
Umr Jansen
6848 POSTS0 COMMENTS