Hi Fredrik,<br><br>Thanks for taking a look at this, I have downloaded the latest PIL source and installed it, and replaced the TiffImagePlugin.py that was in pyShared with the latest one.<br><br>When running my script, I no longer get errors when reading my 16-bit tiff file in.<br>
<br>I do however now get an error when I try and convert and make a grayscale copy of my file, in the middle of my script. (this should be 8bit):<br><br><div style="margin-left: 40px;"><i>  File &quot;16bittest.py&quot;, line 147, in &lt;module&gt;<br>
    im1 = im0.convert (&quot;L&quot;, dither=Image.NONE)<br>  File &quot;/usr/lib/python2.6/dist-packages/PIL/Image.py&quot;, line 654, in convert<br>    self.load()<br>  File &quot;/usr/lib/python2.6/dist-packages/PIL/ImageFile.py&quot;, line 180, in load<br>
    d = Image._getdecoder(self.mode, d, a, self.decoderconfig)<br>  File &quot;/usr/lib/python2.6/dist-packages/PIL/Image.py&quot;, line 374, in _getdecoder<br>    return apply(decoder, (mode,) + args + extra)<br>ValueError: unknown raw mode</i><br>
</div><br>Am I missing a value to pass into convert() to tell it to make an 8bit file?<br><br>Thanks,<br><br><br><div class="gmail_quote">On 25 April 2010 13:48, Fredrik Lundh <span dir="ltr">&lt;<a href="mailto:fredrik@pythonware.com" target="_blank">fredrik@pythonware.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Oops, that patch was broken, due to pilot error.  Here&#39;s an incremental fix:<br>
<br>
<a href="http://hg.effbot.org/pil-2009-raclette/changeset/c3fb89aa181e" target="_blank">http://hg.effbot.org/pil-2009-raclette/changeset/c3fb89aa181e</a><br>
<br>
Alternatively, just grab the latest PIL/TiffImagePlugin.py and<br>
libImaging/Unpack.c and drop them on top of the existing versions.<br>
<font color="#888888"><br>
&lt;/F&gt;<br>
</font><div><div></div><div><br>
On Sun, Apr 25, 2010 at 1:07 PM, Fredrik Lundh &lt;<a href="mailto:fredrik@pythonware.com" target="_blank">fredrik@pythonware.com</a>&gt; wrote:<br>
&gt; This isn&#39;t really a full solution, but the following patch at least<br>
&gt; allows PIL to read 3x16-bit RGB TIFF files, converting them on the fly<br>
&gt; to 24-bit RGB.  Note that it requires new binaries to handle little<br>
&gt; endian (intel) files:<br>
&gt;<br>
&gt; <a href="http://hg.effbot.org/pil-2009-raclette/changeset/45c2debe0fc3" target="_blank">http://hg.effbot.org/pil-2009-raclette/changeset/45c2debe0fc3</a><br>
&gt;<br>
&gt; Unfortunately, your sample use &quot;contiguous&quot; pixel storage, which makes<br>
&gt; the descriptor manipulation tricks I mentioned harder to implement<br>
&gt; efficiently for PIL 1.1.7.  I played a bit with libtiff&#39;s tiffcp<br>
&gt; utility to see if that could be used as a preprocessor (which is<br>
&gt; otherwise a great way to handle more &quot;obscure&quot; TIFF flavours), but at<br>
&gt; least the version I have doesn&#39;t handle 16-bit images well either.  I<br>
&gt; need to think a bit more about this, I think...<br>
&gt;<br>
&gt; &lt;/F&gt;<br>
&gt;<br>
&gt; On Thu, Apr 22, 2010 at 10:57 PM, Fredrik Lundh &lt;<a href="mailto:fredrik@pythonware.com" target="_blank">fredrik@pythonware.com</a>&gt; wrote:<br>
&gt;&gt; Oh, missed that there was one in your first post.  I&#39;m a bit busy<br>
&gt;&gt; right now, but I&#39;ll take a look when I find some spare time.<br>
&gt;&gt;<br>
&gt;&gt; &lt;/F&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Thu, Apr 22, 2010 at 10:56 PM, Fredrik Lundh &lt;<a href="mailto:fredrik@pythonware.com" target="_blank">fredrik@pythonware.com</a>&gt; wrote:<br>
&gt;&gt;&gt; On Tue, Apr 13, 2010 at 10:52 AM, Dan Blacker<br>
&gt;&gt;&gt; &lt;<a href="mailto:dan.blacker@googlemail.com" target="_blank">dan.blacker@googlemail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt; Hey guys,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Thanks for your input,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; The image is only of a tiny cropped area of a long strip of color kodachrome<br>
&gt;&gt;&gt;&gt; film - I will send a better example with some more color in it when I get a<br>
&gt;&gt;&gt;&gt; chance.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I was under the impression that PIL handled 16 bit images (experimentally)<br>
&gt;&gt;&gt;&gt; but does this only apply to 16-bit grayscale images?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Am I going up a dead end trying to read my images with PIL?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The current PIL release only supports 8 and 32-bit/pixel internal<br>
&gt;&gt;&gt; storage; that&#39;s enough to hold e.g. RGB triplets or 32-bit signed<br>
&gt;&gt;&gt; integers, but not 3x16 bit pixels.  I&#39;d love to support more storage<br>
&gt;&gt;&gt; formats (machines are a lot bigger now than when the internal,<br>
&gt;&gt;&gt; intentionally very simple storage model was designed) including HDR<br>
&gt;&gt;&gt; formats (float16 etc), but rearchitecting the internals without<br>
&gt;&gt;&gt; breaking all existing code is a pretty big project...<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; There is some limited support for 16-bit storage, by packing two<br>
&gt;&gt;&gt; pixels per 32-bit storage unit, but not all operations support this<br>
&gt;&gt;&gt; (it&#39;s mainly intended to support working with huge, memory mapped<br>
&gt;&gt;&gt; single-layer images, such as satellite data).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; There are some non-standard tricks that may help you with your<br>
&gt;&gt;&gt; specific case, though.  All codecs do things in two steps; the first<br>
&gt;&gt;&gt; is to identify the file format and build a descriptor of where the<br>
&gt;&gt;&gt; image data is in the file (the &quot;tile&quot; map).  The second step then<br>
&gt;&gt;&gt; loads pixel data on demand, using that descriptor.  You might be able<br>
&gt;&gt;&gt; to tweak the descriptor before loading the image, to load one layer at<br>
&gt;&gt;&gt; a time.  Do you have any samples?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &lt;/F&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>