Vitor Garcia
Vitor Garcia

Reputation: 13

How to erase image created on PIL/Pillow?

I have created an array of monochrome images with:

buffer_pages=[Image.new('1',(width,page_height)) for i in range(pages)]

and I'm drawing on those images with:

whiteboard_pages=[ImageDraw.Draw(page_buffer) for page_buffer in buffer_pages ]

I like to reset one of the images from the array, but I can't find a command that will bring all pixels back to 0 or 1. Is there a PIL method that resets all pixels to a certain value?

Ideally, I'd like something like: buffer_pages[i].reset_all_pixels(color)

whitout using a function that iterates on every pixel an changes it. Speed is quite inportant in my case...

Upvotes: 1

Views: 2216

Answers (1)

bashrc
bashrc

Reputation: 390

Have you tried the method Image.paste?

buffer_pages[i].paste(color, box)

where color is for example 0 and box is a tuple defining the four corners of the image.

Upvotes: 1

Related Questions