How can I create an empty n*m PNG file in Python?

Amir picture Amir · Oct 6, 2012 · Viewed 35.5k times · Source

I would like to combine 4 PNG images to one PNG file. I know who to combine them with Image.paste method, but I couldn't create an save output file! Actually, I want to have a n*m empty PNG file, and use to combine my images. I need to specify the file size, if not I couldn't use paste method.

Answer

John La Rooy picture John La Rooy · Oct 6, 2012
from PIL import Image
image = Image.new('RGB', (n, m))