[Image-SIG] Loading Big-Endian Floating Point TIFF Files

Aaron VanDevender aaron at halcyonmolecular.com
Fri Dec 16 23:07:26 CET 2011


Hello Python Image folks,

I'm using PIL 1.1.7.

I would like to load a TIFF file that stores its pixels in 32-bit
big-endian floating point format. When I use Image.open it reads the file
and mode is given as "F;32BF", however if I use the convert or getdata
methods I get:

/usr/lib/python2.7/dist-packages/PIL/ImageFile.pyc in load_prepare(self)
    229         if not self.im or\
    230            self.im.mode != self.mode or self.im.size != self.size:
--> 231             self.im = Image.core.new(self.mode, self.size)
    232         # create palette (optional)

    233         if self.mode == "P":

ValueError: unrecognized mode


However, if I say

    image_tiff = Image.open(file_tiff)

    if image_tiff.mode == "F;32BF":
        image_tiff.mode = "F"
    image = numpy.asarray(image_tiff)

It will .convert() properly. It seems that there is a bug in the TIFF
loader that is mistaking the raw mode for the mode.

-Aaron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20111216/a432aa5f/attachment.html>


More information about the Image-SIG mailing list