title: Python PIL struggles with uncompressed 16-bit TIFF images
body: <p>My system is Mac OS X v10.8.2.  I have several 2560x500 uncompressed 16-bit TIFF images (grayscale, unsigned 16-bit integers).  I first attempt to load them using PIL (installed via Homebrew, version 1.7.8):</p>
  
  <pre><code>from PIL import Image
  import numpy as np
  
  filename = 'Rocks_2ptCal_750KHz_20ms_1ma_120KV_2013-03-06_20-02-12.tif'
  img = Image.open(filename)
  
  # &gt;&gt;&gt; img
  # &lt;PIL.TiffImagePlugin.TiffImageFile image mode=I;16B size=2560x500 at 0x10A383C68&gt;
  
  img.show() 
  
  # almost all pixels displayed as white.  Not correct.  
  # MatLab, EZ-draw, even Mac Preview show correct images in grayscale.
  
  imgdata = list(img.getdata()) 
  
  # most values negative:
  # &gt;&gt;&gt; imgdata[0:10]
  # [-26588, -24079, -27822, -26045, -27245, -25368, -26139, -28454, -30675, -28455]
  
  imgarray = np.asarray(imgdata, dtype=np.uint16) 
  
  # values now correct
  # &gt;&gt;&gt; imgarray
  # array([38948, 41457, 37714, ..., 61922, 59565, 60035], dtype=uint16)
  </code></pre>
  
  <p>The negative values are off by 65,536... probably not a coincidence.</p>
  
  <p>If I pretend to alter pixels and revert back to TIFF image via PIL (by just putting the array back as an image):</p>
  
  <pre><code>newimg = Image.fromarray(imgarray)
  </code></pre>
  
  <p>I get errors:</p>
  
  <pre><code>File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 1884, in fromarray
      raise TypeError("Cannot handle this data type")
  TypeError: Cannot handle this data type
  </code></pre>
  
  <p>I can't find <code>Image.fromarray()</code> in the PIL documentation.  I've tried loading via <code>Image.fromstring()</code>, but I don't understand the PIL documentation and there is little in the way of example.</p>
  
  <p>As shown in the code above, PIL seems to "detect" the data as <code>I;16B</code>.  From what I can tell from the PIL docs, mode <code>I</code> is:</p>
  
  <pre><code>*I* (32-bit signed integer pixels)
  </code></pre>
  
  <p>Obviously, that is not correct.</p>
  
  <p>I find many posts on SX suggesting that PIL doesn't support 16-bit images.  I've found suggestions to use pylibtiff, but I believe that is Windows only?</p>
  
  <p>I am looking for a "lightweight" way to work with these TIFF images in Python.  I'm surprised it is this difficult and that leads me to believe the problem will be obvious to others.</p>