[Image-SIG] Re: 16bit PNG read/write supported ?
Fredrik Lundh
fredrik@pythonware.com
Thu, 8 May 2003 12:02:11 +0200
Sebastian Haase wrote:
> I am about to start using PIL. We (BioChemistry department
> at UCSF) are dealing with grayscale images that are 16
> bits per pixel (if not floating point).
> I read that the latest (beta) version of PIL should now
> support 16bit TIFF images ...
>
> What is the status regarding 16bit gray images with PNG ?
if I remember correctly, and interpret the code correctly, PIL reads
16-bit monochrome PNG files as mode "I" images (that is, it uses 32-
bit internal storage).
I don't have any 16-bit samples on this box (and no time to google
for them), but roundtripping sure seems to work:
>>> import Image
>>> im = Image.new("I", (100, 100))
>>> im.putdata(range(10000))
>>> im.getpixel((50, 50))
5050
>>> im.save("out.png")
>>> im = Image.open("out.png")
>>> im.mode
'I'
>>> im.size
(100, 100)
>>> im.getpixel((50, 50))
5050
</F>