What did you do?
Tried to load an Image from a TIFF file on disk; code below.
I just tried to attach the file to this ticket, but GH won't let me as the file is 172MB and the limit is 10MB, so I've put it up in dropbox:
https://dl.dropboxusercontent.com/u/13625221/ARC-1980-AC80-0453.tif
What did you expect to happen?
Load up the TIFF file as an Image object I could operate on
What actually happened?
Throws an exception
What versions of Pillow and Python are you using?
Pillow-3.1.0.dist-info
Python 3.4.3 (default, Jul 13 2015, 12:18:23)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Please include code that reproduces the issue and whenever possible, an image that demonstrates the issue. The best reproductions are self-contained scripts with minimal dependencies.
>>> from PIL import Image
>>> Image.open('/Users/chris/Pictures/ARC-1980-AC80-0453.tif')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py", line 2295, in open
% (filename if filename else fp))
OSError: cannot identify image file '/Users/chris/Pictures/ARC-1980-AC80-0453.tif'
This is reported by Image.py:2294, and is caused by line 2275, the factory() call:
try:
factory, accept = OPEN[i]
if not accept or accept(prefix):
fp.seek(0)
im = factory(fp, filename)
_decompression_bomb_check(im.size)
return im
except (SyntaxError, IndexError, TypeError, struct.error):
Debugging shows it throws:
SyntaxError: unknown pixel mode
(Pdb) n
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2271)_open_core()
-> try:
(Pdb) pp i
'TIFF'
(Pdb) n
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2272)_open_core()
-> factory, accept = OPEN[i]
(Pdb) n
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2273)_open_core()
-> if not accept or accept(prefix):
(Pdb) pp factory, accept
(<class 'PIL.TiffImagePlugin.TiffImageFile'>,
<function _accept at 0x10c5208c8>)
(Pdb) n
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2274)_open_core()
-> fp.seek(0)
(Pdb) n
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2275)_open_core()
-> im = factory(fp, filename)
(Pdb) n
SyntaxError: unknown pixel mode
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2275)_open_core()
-> im = factory(fp, filename)
and that's happening in ImageFile.py:97: self._open():
try:
self._open()
except (IndexError, # end of data
TypeError, # end of data (ord)
KeyError, # unsupported mode
EOFError, # got header but not the first frame
struct.error) as v:
raise SyntaxError(v)
And this invokes the TiffImagePlugin.py where it fails at 899: self._seek(0). If I set DEBUG=True and PDB through it, we get some useful hints -- an "unsupported format".
(Pdb) n
tag: NewSubfileType (254) - type: long (4) - value: 0
tag: ImageWidth (256) - type: short (3) - value: 4808
tag: ImageLength (257) - type: short (3) - value: 6003
tag: BitsPerSample (258) - type: short (3) Tag Location: 58 - Data Location: 290 - value: (16, 16, 16)
tag: Compression (259) - type: short (3) - value: 1
tag: PhotometricInterpretation (262) - type: short (3) - value: 2
tag: Make (271) - type: string (2) Tag Location: 94 - Data Location: 296 - value: Epson
tag: Model (272) - type: string (2) Tag Location: 106 - Data Location: 306 - value: Perfection4990
tag: StripOffsets (273) - type: long (4) - value: (30080,)
tag: Orientation (274) - type: short (3) - value: 1
tag: SamplesPerPixel (277) - type: short (3) - value: 3
tag: RowsPerStrip (278) - type: short (3) - value: 6003
tag: StripByteCounts (279) - type: long (4) - value: (173174544,)
tag: XResolution (282) - type: rational (5) Tag Location: 178 - Data Location: 324 - value: 600.0
tag: YResolution (283) - type: rational (5) Tag Location: 190 - Data Location: 332 - value: 600.0
tag: PlanarConfiguration (284) - type: short (3) - value: 1
tag: ResolutionUnit (296) - type: short (3) - value: 2
tag: Software (305) - type: string (2) Tag Location: 226 - Data Location: 340 - value: Adobe Photoshop CS3 Macintosh
tag: DateTime (306) - type: string (2) Tag Location: 238 - Data Location: 370 - value: 2008:12:19 13:22:17
tag: XMP (700) - type: byte (1) Tag Location: 250 - Data Location: 390 - value: <table: 15290 bytes>
tag: PhotoshopInfo (34377) - type: byte (1) Tag Location: 262 - Data Location: 15680 - value: <table: 13840 bytes>
tag: ExifIFD (34665) - type: long (4) - value: 173204624
tag: ICCProfile (34675) - type: undefined (7) Tag Location: 286 - Data Location: 29520 - value: <table: 560 bytes>
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(954)_seek()
-> self.__next = self.tag_v2.next
(Pdb) n
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(955)_seek()
-> self.__frame += 1
(Pdb) n
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(939)_seek()
-> while len(self._frame_pos) <= frame:
(Pdb) n
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(956)_seek()
-> self.fp.seek(self._frame_pos[frame])
(Pdb) n
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(957)_seek()
-> self.tag_v2.load(self.fp)
(Pdb) n
tag: NewSubfileType (254) - type: long (4) - value: 0
tag: ImageWidth (256) - type: short (3) - value: 4808
tag: ImageLength (257) - type: short (3) - value: 6003
tag: BitsPerSample (258) - type: short (3) Tag Location: 58 - Data Location: 290 - value: (16, 16, 16)
tag: Compression (259) - type: short (3) - value: 1
tag: PhotometricInterpretation (262) - type: short (3) - value: 2
tag: Make (271) - type: string (2) Tag Location: 94 - Data Location: 296 - value: Epson
tag: Model (272) - type: string (2) Tag Location: 106 - Data Location: 306 - value: Perfection4990
tag: StripOffsets (273) - type: long (4) - value: (30080,)
tag: Orientation (274) - type: short (3) - value: 1
tag: SamplesPerPixel (277) - type: short (3) - value: 3
tag: RowsPerStrip (278) - type: short (3) - value: 6003
tag: StripByteCounts (279) - type: long (4) - value: (173174544,)
tag: XResolution (282) - type: rational (5) Tag Location: 178 - Data Location: 324 - value: 600.0
tag: YResolution (283) - type: rational (5) Tag Location: 190 - Data Location: 332 - value: 600.0
tag: PlanarConfiguration (284) - type: short (3) - value: 1
tag: ResolutionUnit (296) - type: short (3) - value: 2
tag: Software (305) - type: string (2) Tag Location: 226 - Data Location: 340 - value: Adobe Photoshop CS3 Macintosh
tag: DateTime (306) - type: string (2) Tag Location: 238 - Data Location: 370 - value: 2008:12:19 13:22:17
tag: XMP (700) - type: byte (1) Tag Location: 250 - Data Location: 390 - value: <table: 15290 bytes>
tag: PhotoshopInfo (34377) - type: byte (1) Tag Location: 262 - Data Location: 15680 - value: <table: 13840 bytes>
tag: ExifIFD (34665) - type: long (4) - value: 173204624
tag: ICCProfile (34675) - type: undefined (7) Tag Location: 286 - Data Location: 29520 - value: <table: 560 bytes>
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(959)_seek()
-> self.tag = self.ifd = ImageFileDirectory_v1.from_v2(self.tag_v2)
(Pdb) c
*** Summary ***
- compression: raw
- photometric_interpretation: 2
- planar_configuration: 1
- fill_order: 1
- size: (4808, 6003)
format key: (b'MM', 2, (1,), 1, (16, 16, 16), ())
- unsupported format
> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2276)_open_core()
This format key is not in the OPEN_INFO dict, and I'm not seeing any others with BitsPerSample=(16, 16, 16).
And now I'm totally out of my league. :-(
The only other hit on the original error message I've seen is this thread from 2012:
http://www.aps.anl.gov/epics/tech-talk/2012/msg00622.php
where they discuss 32-bit TIFFs.
FWIW, OSX "Preview" app can open it, display, and convert to JPEG, so it seems this TIFF variant is something PIL needs to know about.
Thanks for any help you can provide!
What did you do?
Tried to load an Image from a TIFF file on disk; code below.
I just tried to attach the file to this ticket, but GH won't let me as the file is 172MB and the limit is 10MB, so I've put it up in dropbox:
https://dl.dropboxusercontent.com/u/13625221/ARC-1980-AC80-0453.tif
What did you expect to happen?
Load up the TIFF file as an Image object I could operate on
What actually happened?
Throws an exception
What versions of Pillow and Python are you using?
Pillow-3.1.0.dist-info
Python 3.4.3 (default, Jul 13 2015, 12:18:23)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Please include code that reproduces the issue and whenever possible, an image that demonstrates the issue. The best reproductions are self-contained scripts with minimal dependencies.
This is reported by Image.py:2294, and is caused by line 2275, the factory() call:
Debugging shows it throws:
SyntaxError: unknown pixel mode
and that's happening in ImageFile.py:97: self._open():
And this invokes the TiffImagePlugin.py where it fails at 899: self._seek(0). If I set DEBUG=True and PDB through it, we get some useful hints -- an "unsupported format".
This format key is not in the OPEN_INFO dict, and I'm not seeing any others with BitsPerSample=(16, 16, 16).
And now I'm totally out of my league. :-(
The only other hit on the original error message I've seen is this thread from 2012:
http://www.aps.anl.gov/epics/tech-talk/2012/msg00622.php
where they discuss 32-bit TIFFs.
FWIW, OSX "Preview" app can open it, display, and convert to JPEG, so it seems this TIFF variant is something PIL needs to know about.
Thanks for any help you can provide!