Gautham Narayan wrote:
I'm having trouble understanding the behaviour of Image.crop (PIL
1.1.6 w/ python 2.5.1) when the bbox is outside the limits of the
image. So something like,
b = a.crop(x1,y1,x2,y2)
with x1 and y1 < 0 say.
Sometimes I get a purely black border (which is good), sometimes I
Ned Batchelder wrote:
If your image is single-channel (mode "L"), then you can use the eval
function:
img = Image.open("onechannel.png")
# at each pixel, if it isn't zero, make it 255..
better = Image.eval(img, lambda p: 255 * (int(p != 0)))
better.save("bilevel.png")
if you want