[Image-SIG] Saving 12-bit grayscale from PIL

Jonathan M. Gilligan jonathan.gilligan@vanderbilt.edu
Mon, 17 Sep 2001 16:54:45 -0500


I am working extensively with images recorded as 12-bit grayscale.

I can successfully read in the raw data using array.array and convert it to 
an "I" mode PIL image, but I can't then save it, since I can't find a 
compatible file format for output. The FORMATS file suggests that I should 
be able to save an "I" image to .png, but when I try to save a 128 * 256 
"I" image to file as a .png image, PIL dumps core.

I am using ActiveState Python 2.1 for Windows and PIL 1.1.1 (obtained using 
the ActiveState package manager). When I try to save the image from PIL 
using "img.save('foo.png','PNG')", where img is an Image.Image object, 
python tells me, "C:\Python21\PIL\EpsImagePlugin.py:23: DeprecationWarning: 
the regex module is deprecated; please use the re module import regex, 
string" and then crashes python with an illegal memory access.

Does anyone have any suggestions for working with 12-bit grayscale images 
using PIL?

Thanks,
Jonathan Gilligan