Jan-24-2023, 01:35 PM
Hi!
I've been learning how to use the various packages and methods in the Pillow library (v9.4.0 under Python 3.7.9), but I have a question about the ImagePath.Path class in the ImagePath module. If I run the example below, I get the same result whether I pass a Path object to Image.line() or I pass an ordinary list of tuples. So is there any reason to use ImagePath if you don't need to call any of its methods (compact(),getbox(), map(), toList(), transform())? In other words, simply creating an Path object doesn't really do anything? It's only the associated methods that do anything useful?
I've been learning how to use the various packages and methods in the Pillow library (v9.4.0 under Python 3.7.9), but I have a question about the ImagePath.Path class in the ImagePath module. If I run the example below, I get the same result whether I pass a Path object to Image.line() or I pass an ordinary list of tuples. So is there any reason to use ImagePath if you don't need to call any of its methods (compact(),getbox(), map(), toList(), transform())? In other words, simply creating an Path object doesn't really do anything? It's only the associated methods that do anything useful?
from PIL import Image, ImageDraw, ImagePath img = Image.new("RGB",(800,400),(255,255,0)) cnv = ImageDraw.Draw(img) #path = [(0,0),(250,300),(500,250),(0,0)] path = ImagePath.Path([(0,0),(250,300),(500,250),(0,0)]) cnv.line(path,(0,0,0),3) img.save("test.jpg")