img = Image.fromarray(rawimg, '1')
because a true will be interpreted as integer 1 ), so that 7 pixels
are black and one white. Has someone a solution, so that a picture
inly with "true" values doesn't look like this?
This has come up before, see
http://mail.python.org/pipermail/python-list/2009-October/1221578.html
Image.fromarray() expects one bit per pixel but actually gets one byte. One
possible workaround: introduce an intermediate array with a format
understood by fromarray():
>>> import numpy
>>> from PIL import Image
>>> rawimg = numpy.zeros((20, 20), bool)
>>> rawimg[:10, :10] = rawimg[10:, 10:] = True
>>> b = numpy.array(rawimg, numpy.uint8)
>>> b *= 255
>>> Image.fromarray(b).save("tmp.jpg")
Peter
> Peter
Thank you!