{"action":"closed","issue":{"url":"https://api.github.com/repos/python-pillow/Pillow/issues/1885","repository_url":"https://api.github.com/repos/python-pillow/Pillow","labels_url":"https://api.github.com/repos/python-pillow/Pillow/issues/1885/labels{/name}","comments_url":"https://api.github.com/repos/python-pillow/Pillow/issues/1885/comments","events_url":"https://api.github.com/repos/python-pillow/Pillow/issues/1885/events","html_url":"https://github.com/python-pillow/Pillow/issues/1885","id":153061741,"number":1885,"title":"Image.open(tiff_file): OSError: cannot identify image file","user":{"login":"shentonfreude","id":68655,"avatar_url":"https://avatars.githubusercontent.com/u/68655?v=3","gravatar_id":"","url":"https://api.github.com/users/shentonfreude","html_url":"https://github.com/shentonfreude","followers_url":"https://api.github.com/users/shentonfreude/followers","following_url":"https://api.github.com/users/shentonfreude/following{/other_user}","gists_url":"https://api.github.com/users/shentonfreude/gists{/gist_id}","starred_url":"https://api.github.com/users/shentonfreude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shentonfreude/subscriptions","organizations_url":"https://api.github.com/users/shentonfreude/orgs","repos_url":"https://api.github.com/users/shentonfreude/repos","events_url":"https://api.github.com/users/shentonfreude/events{/privacy}","received_events_url":"https://api.github.com/users/shentonfreude/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/python-pillow/Pillow/labels/Enhancement","name":"Enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-04T16:48:36Z","updated_at":"2016-05-04T20:52:17Z","closed_at":"2016-05-04T20:52:17Z","body":"### What did you do?\r\n\r\nTried to load an Image from a TIFF file on disk; code below.\r\n\r\nI 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:\r\nhttps://dl.dropboxusercontent.com/u/13625221/ARC-1980-AC80-0453.tif\r\n\r\n### What did you expect to happen?\r\n\r\nLoad up the TIFF file as an Image object I could operate on\r\n\r\n### What actually happened?\r\n\r\nThrows an exception\r\n\r\n### What versions of Pillow and Python are you using?\r\nPillow-3.1.0.dist-info\r\nPython 3.4.3 (default, Jul 13 2015, 12:18:23) \r\n[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin\r\n\r\nPlease 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.\r\n\r\n```python\r\n>>> from PIL import Image\r\n>>> Image.open('/Users/chris/Pictures/ARC-1980-AC80-0453.tif')\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py\", line 2295, in open\r\n    % (filename if filename else fp))\r\nOSError: cannot identify image file '/Users/chris/Pictures/ARC-1980-AC80-0453.tif'\r\n```\r\n\r\nThis is reported by Image.py:2294, and is caused by line 2275, the factory() call:\r\n\r\n```python\r\n            try:\r\n                factory, accept = OPEN[i]\r\n                if not accept or accept(prefix):\r\n                    fp.seek(0)\r\n                    im = factory(fp, filename)\r\n                    _decompression_bomb_check(im.size)\r\n                    return im\r\n            except (SyntaxError, IndexError, TypeError, struct.error):\r\n```\r\nDebugging shows it throws: \r\n\r\nSyntaxError: unknown pixel mode\r\n\r\n```python\r\n(Pdb) n\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2271)_open_core()\r\n-> try:\r\n(Pdb) pp i\r\n'TIFF'\r\n(Pdb) n\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2272)_open_core()\r\n-> factory, accept = OPEN[i]\r\n(Pdb) n\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2273)_open_core()\r\n-> if not accept or accept(prefix):\r\n(Pdb) pp factory, accept\r\n(<class 'PIL.TiffImagePlugin.TiffImageFile'>,\r\n <function _accept at 0x10c5208c8>)\r\n(Pdb) n\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2274)_open_core()\r\n-> fp.seek(0)\r\n(Pdb) n\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2275)_open_core()\r\n-> im = factory(fp, filename)\r\n(Pdb) n\r\nSyntaxError: unknown pixel mode\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2275)_open_core()\r\n-> im = factory(fp, filename)\r\n```\r\n\r\nand that's happening in ImageFile.py:97: self._open():\r\n\r\n```python\r\n        try:\r\n            self._open()\r\n        except (IndexError,  # end of data\r\n                TypeError,  # end of data (ord)\r\n                KeyError,  # unsupported mode\r\n                EOFError,  # got header but not the first frame\r\n                struct.error) as v:\r\n            raise SyntaxError(v)\r\n```\r\n\r\nAnd 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\". \r\n\r\n```python\r\n(Pdb) n\r\ntag: NewSubfileType (254) - type: long (4) - value: 0\r\ntag: ImageWidth (256) - type: short (3) - value: 4808\r\ntag: ImageLength (257) - type: short (3) - value: 6003\r\ntag: BitsPerSample (258) - type: short (3) Tag Location: 58 - Data Location: 290 - value: (16, 16, 16)\r\ntag: Compression (259) - type: short (3) - value: 1\r\ntag: PhotometricInterpretation (262) - type: short (3) - value: 2\r\ntag: Make (271) - type: string (2) Tag Location: 94 - Data Location: 296 - value: Epson   \r\ntag: Model (272) - type: string (2) Tag Location: 106 - Data Location: 306 - value: Perfection4990  \r\ntag: StripOffsets (273) - type: long (4) - value: (30080,)\r\ntag: Orientation (274) - type: short (3) - value: 1\r\ntag: SamplesPerPixel (277) - type: short (3) - value: 3\r\ntag: RowsPerStrip (278) - type: short (3) - value: 6003\r\ntag: StripByteCounts (279) - type: long (4) - value: (173174544,)\r\ntag: XResolution (282) - type: rational (5) Tag Location: 178 - Data Location: 324 - value: 600.0\r\ntag: YResolution (283) - type: rational (5) Tag Location: 190 - Data Location: 332 - value: 600.0\r\ntag: PlanarConfiguration (284) - type: short (3) - value: 1\r\ntag: ResolutionUnit (296) - type: short (3) - value: 2\r\ntag: Software (305) - type: string (2) Tag Location: 226 - Data Location: 340 - value: Adobe Photoshop CS3 Macintosh\r\ntag: DateTime (306) - type: string (2) Tag Location: 238 - Data Location: 370 - value: 2008:12:19 13:22:17\r\ntag: XMP (700) - type: byte (1) Tag Location: 250 - Data Location: 390 - value: <table: 15290 bytes>\r\ntag: PhotoshopInfo (34377) - type: byte (1) Tag Location: 262 - Data Location: 15680 - value: <table: 13840 bytes>\r\ntag: ExifIFD (34665) - type: long (4) - value: 173204624\r\ntag: ICCProfile (34675) - type: undefined (7) Tag Location: 286 - Data Location: 29520 - value: <table: 560 bytes>\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(954)_seek()\r\n-> self.__next = self.tag_v2.next\r\n(Pdb) n\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(955)_seek()\r\n-> self.__frame += 1\r\n(Pdb) n\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(939)_seek()\r\n-> while len(self._frame_pos) <= frame:\r\n(Pdb) n\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(956)_seek()\r\n-> self.fp.seek(self._frame_pos[frame])\r\n(Pdb) n\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(957)_seek()\r\n-> self.tag_v2.load(self.fp)\r\n(Pdb) n\r\ntag: NewSubfileType (254) - type: long (4) - value: 0\r\ntag: ImageWidth (256) - type: short (3) - value: 4808\r\ntag: ImageLength (257) - type: short (3) - value: 6003\r\ntag: BitsPerSample (258) - type: short (3) Tag Location: 58 - Data Location: 290 - value: (16, 16, 16)\r\ntag: Compression (259) - type: short (3) - value: 1\r\ntag: PhotometricInterpretation (262) - type: short (3) - value: 2\r\ntag: Make (271) - type: string (2) Tag Location: 94 - Data Location: 296 - value: Epson   \r\ntag: Model (272) - type: string (2) Tag Location: 106 - Data Location: 306 - value: Perfection4990  \r\ntag: StripOffsets (273) - type: long (4) - value: (30080,)\r\ntag: Orientation (274) - type: short (3) - value: 1\r\ntag: SamplesPerPixel (277) - type: short (3) - value: 3\r\ntag: RowsPerStrip (278) - type: short (3) - value: 6003\r\ntag: StripByteCounts (279) - type: long (4) - value: (173174544,)\r\ntag: XResolution (282) - type: rational (5) Tag Location: 178 - Data Location: 324 - value: 600.0\r\ntag: YResolution (283) - type: rational (5) Tag Location: 190 - Data Location: 332 - value: 600.0\r\ntag: PlanarConfiguration (284) - type: short (3) - value: 1\r\ntag: ResolutionUnit (296) - type: short (3) - value: 2\r\ntag: Software (305) - type: string (2) Tag Location: 226 - Data Location: 340 - value: Adobe Photoshop CS3 Macintosh\r\ntag: DateTime (306) - type: string (2) Tag Location: 238 - Data Location: 370 - value: 2008:12:19 13:22:17\r\ntag: XMP (700) - type: byte (1) Tag Location: 250 - Data Location: 390 - value: <table: 15290 bytes>\r\ntag: PhotoshopInfo (34377) - type: byte (1) Tag Location: 262 - Data Location: 15680 - value: <table: 13840 bytes>\r\ntag: ExifIFD (34665) - type: long (4) - value: 173204624\r\ntag: ICCProfile (34675) - type: undefined (7) Tag Location: 286 - Data Location: 29520 - value: <table: 560 bytes>\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/TiffImagePlugin.py(959)_seek()\r\n-> self.tag = self.ifd = ImageFileDirectory_v1.from_v2(self.tag_v2)\r\n(Pdb) c\r\n*** Summary ***\r\n- compression: raw\r\n- photometric_interpretation: 2\r\n- planar_configuration: 1\r\n- fill_order: 1\r\n- size: (4808, 6003)\r\nformat key: (b'MM', 2, (1,), 1, (16, 16, 16), ())\r\n- unsupported format\r\n> /Users/chris/.virtualenvs/avail_imageresizer/lib/python3.4/site-packages/PIL/Image.py(2276)_open_core()\r\n```\r\n\r\nThis format key is not in the OPEN_INFO dict, and I'm not seeing any others with BitsPerSample=(16, 16, 16).\r\n\r\nAnd now I'm totally out of my league. :-(\r\n\r\nThe only other hit on the original error message I've seen is this thread from 2012:\r\nhttp://www.aps.anl.gov/epics/tech-talk/2012/msg00622.php\r\nwhere they discuss 32-bit TIFFs.\r\n\r\nFWIW, OSX \"Preview\" app can open it, display, and convert to JPEG, so it seems this TIFF variant is something PIL needs to know about. \r\n\r\nThanks for any help you can provide!"}}