[Image-SIG] Does PIL support the sBIT chunk in PNG files?

Andrew Hawryluk HAWRYLA at novachem.com
Fri Nov 30 17:51:35 CET 2007


Thanks to everyone that is using and developing PIL - it has been most helpful!

I am working with a 16-bit greyscale PNGs created by LabVIEW (currently 14695 of them). They were captured on a 12-bit camera and encoded with the "sBIT" chunk, scaling the values up to 16-bit values as described in the PNG specs, section 12.5. Opening the images with PIL I get the full 16-bit values, but I need the original values. (The rescaling I need is described in the PNG specs, section 13.12.) The problem is additionally complicated by the fact that some of the darker images use only 10 or 11 of the available bits in the camera and LabVIEW also scales these to the full 16 bits available, so blindly dividing all images by a constant will not solve the problem.

As a workaround, I am opening each file and reading the "sBIT" byte directly and then using an integer division to restore the original camera values. This has solved my problem, but it would be better if I knew how to ask PIL to do the work for me.

PNG specification: http://www.w3.org/TR/PNG/

Thanks again,

Andrew
Calgary, Canada
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/image-sig/attachments/20071130/a3408910/attachment.htm 


More information about the Image-SIG mailing list