What's the mode for this image?  If it says "I;16" or something
similar, it's not fully supported in 1.1.6, and you may have to
explicitly convert it to mode "I" to work with it.

(there should be an option to open() so you can explicitly tell PIL if
you're prepared to work with experimental modes, really, but with the
current releases, you have to look for them).

</F>

On Thu, Jan 22, 2009 at 9:05 PM, Tim Hoffmann
<hoffm...@hiskp.uni-bonn.de> wrote:
> Hello,
>
> I think I found a bug in Image.putpixel() for 16bit images. It writes the
> given x coordinates in bytes, not pixels. i.e. x==0 is lower byte of pixel
> 0, x==1 addresses upper byte of pixel zero. y indices are ok.
>
>
> The following code shows the problem (using PIL 1.1.6):
>
>
> im = Image.open("text16black.tif")
>    print im.format, im.size, im.mode
>    dx = size[0]
>
>    for i in range(0, dx):
>        # reopening to restore data every time
>        im = Image.open("test16black.tif")
>        im.putpixel((i, 0), 2)
>        print [im.getpixel((x, 0)) for x in range(0, dx)]
>
> output (for completely black test image):
>
> TIFF (9, 15) I;16
> [2, 0, 0, 0, 0, 0, 0, 0, 0]
> [512, 0, 0, 0, 0, 0, 0, 0, 0]
> [0, 2, 0, 0, 0, 0, 0, 0, 0]
> [0, 512, 0, 0, 0, 0, 0, 0, 0]
> [0, 0, 2, 0, 0, 0, 0, 0, 0]
> [0, 0, 512, 0, 0, 0, 0, 0, 0]
> [0, 0, 0, 2, 0, 0, 0, 0, 0]
> [0, 0, 0, 512, 0, 0, 0, 0, 0]
> [0, 0, 0, 0, 2, 0, 0, 0, 0]
>
>
>
> Because of range checking based on the pixels I cannot even work around
> supplying the data in an appropriate format. There is no way to address the
> right half of the line.
>
> BTW the same problem occurs in putdata().
>
> Thanks for your comments,
> Tim
>
>
> _______________________________________________
> Image-SIG maillist  -  Image-SIG@python.org
> http://mail.python.org/mailman/listinfo/image-sig
>
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to