title: Python and 16 Bit Tiff
body: <p>How can I convert and save a 16 bit single-channel TIF in Python?</p>
  
  <p>I can load a 16 and 32 bit image without an issue, and see that the 32 bit image is mode <code>F</code> and the 16 bit image is mode <code>I;16S</code>:</p>
  
  <pre><code>import Image
  i32 = Image.open('32.tif')
  i16 = Image.open('16.tif')
  i32
  # &lt;TiffImagePlugin.TiffImageFile image mode=F size=2000x1600 at 0x1098E5518&gt;
  i16
  # &lt;TiffImagePlugin.TiffImageFile image mode=I;16S size=2000x1600 at 0x1098B6DD0&gt;
  </code></pre>
  
  <p>But I am having trouble working with the 16 bit image. If I want to save either as PNG, I cannot do so directly:</p>
  
  <pre><code>i32.save('foo.png')
  # IOError: cannot write mode F as PNG
  i16.save('foo.png')
  # ValueError: unrecognized mode
  </code></pre>
  
  <p>If I convert the 32 bit image, I can save it:</p>
  
  <pre><code>i32.convert('L').save('foo.png')
  </code></pre>
  
  <p>But the same command will not work with the 16 bit image:</p>
  
  <pre><code>i16.convert('L').save('foo.png')
  # ValueError: unrecognized mode
  </code></pre>