Playing with PIL (and numpy) for the first time ever. I was trying to generate a black and white checkerboard image through mode=\'1\', but it doesn\'t work.
Just use PyPNG:
import numpy as np
if __name__ == '__main__':
g = np.asarray(dtype=np.dtype('uint8'), a=[
[0, 1, 0, 1, 0, 1, 0, 1, ],
[1, 0, 1, 0, 1, 0, 1, 0, ],
[0, 1, 0, 1, 0, 1, 0, 1, ],
[1, 0, 1, 0, 1, 0, 1, 0, ],
[0, 1, 0, 1, 0, 1, 0, 1, ],
[1, 0, 1, 0, 1, 0, 1, 0, ],
[0, 1, 0, 1, 0, 1, 0, 1, ],
[1, 0, 1, 0, 1, 0, 1, 0, ],
])
print(g)
import png
i = png.from_array(g, mode='L;1')
i.save('checker.png')