I am using PIL for my project and I have ImageDraw object. I want to get the image that is drawn on ImageDraw object. How do I get the image ?
Is THIS what you are looking for?
from PIL import Image, ImageDraw
im = Image.new('RGBA', (400, 400), (0, 255, 0, 0))
draw = ImageDraw.Draw(im)
draw.text((20, 20), "DRAW TEXT", fill="red")
draw.polygon([(5,5), (25,5), (25,20), (5,25)], fill="green", outline=None)
im.show()
im.save("ImageDraw.png")
Here is the ImageDraw.png
image file (resized 300%):
Here the draw
object is used for drawing polygons in the image. While drawing to the draw
object you changed the im
object.
P.S. check out also :
Drawing a line on an image with pil
Python imaging library save function