Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
16-bit TIFF files truncated to 0..255 before conversion to float #274
Example data file: https://dl.dropboxusercontent.com/u/3720/junk/12bit.tif (a 16-bit TIFF container with pixel values spanning a 12-bit range, which is common in scientific imaging)
Opening the file with Image.open gives the expected result:
But converting to a float type clips all pixel values above 255 to 255:
Conversion to float should not clip 16-bit integer values.
It appears (from Convert.c) that there's no direct conversion from I;16 to F. There are I to F, and I;16 to I, but nothing that works in one step. [edit, though, I'm not actually seeing how it should work at all, since it should return a conversion not supported error. edit 2, this https://github.com/python-imaging/Pillow/blob/master/PIL/Image.py#L703 is the truncation. ]
It looks like a conversion for the I;16 modes -> F should be straight forward.