Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to open OME-TIFF example data files #811

Closed
anntzer opened this issue Jul 20, 2014 · 7 comments · Fixed by #7111
Closed

Fails to open OME-TIFF example data files #811

anntzer opened this issue Jul 20, 2014 · 7 comments · Fixed by #7111
Labels
Projects

Comments

@anntzer
Copy link
Contributor

anntzer commented Jul 20, 2014

OME-TIFF is a TIFF format that embeds some microscopy-specific metadata as an XML comment embedded in the TIFF header. Sample data is available at https://www.openmicroscopy.org/site/support/ome-model/ome-tiff/data.html, but PIL fails to open single-channel.ome.tiff (throwing OSError: cannot identify image file 'single-channel.ome.tiff').

@hugovk
Copy link
Member

hugovk commented Jul 20, 2014

I'm not at a computer to test, but just to confirm: does this happen with Pillow (the PIL fork)? Which version of Pillow do you have?

@anntzer
Copy link
Contributor Author

anntzer commented Jul 20, 2014

Yes, this is with Pillow 2.5.0, Python 3.4. I actually haven't tested this with PIL.

@wiredfool
Copy link
Member

wiredfool commented Jul 20, 2014

The actual problem with that file is that it is specified as a bigendian 8-bit signed integer format, which we don't have listed in the formats that we support. This past includes a mode line that will read the format and store it in an unsigned integer. Visual inspection of the image looks okay. The XML from the OME format shows up in the tags directory.

diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py
index 2e49931..d96542a 100644
--- a/PIL/TiffImagePlugin.py
+++ b/PIL/TiffImagePlugin.py
@@ -185,6 +185,7 @@ OPEN_INFO = {
     (MM, 1, 1, 1, (1,), ()): ("1", "1"),
     (MM, 1, 1, 2, (1,), ()): ("1", "1;R"),
     (MM, 1, 1, 1, (8,), ()): ("L", "L"),
+    (MM, 1, 2, 1, (8,), ()): ("L", "L"), #signed 8 bit???
     (MM, 1, 1, 1, (8,8), (2,)): ("LA", "LA"),
     (MM, 1, 1, 2, (8,), ()): ("L", "L;R"),
     (MM, 1, 1, 1, (16,), ()): ("I;16B", "I;16B"),

@anntzer
Copy link
Contributor Author

anntzer commented Jul 20, 2014

The Image file formats doc does not mention this limitation. Is this a non-standard TIFF format? (I don't know.)

@wiredfool
Copy link
Member

There are many combinations, we support 60 or more of them. See lines ~145->212 of TiffImagePlugin for the combinations. I've never seen a signed 8bit image before, so if it's not rare, it's not exactly common either.

We don't have a specific mode for signed 8 bit images, so while we can read the image, we don't actually report the bytes correctly. (we'd return 0-255, not -127->127).

@wiredfool wiredfool added the TIFF label Nov 27, 2014
@radarhere
Copy link
Member

@radarhere radarhere changed the title PIL fails to open OME-TIFF example data files Fails to open OME-TIFF example data files Apr 14, 2019
@aclark4life aclark4life added this to Backlog in Pillow May 11, 2019
@aclark4life aclark4life moved this from Backlog to In progress in Pillow May 11, 2019
@radarhere
Copy link
Member

I've created PR #7111 to resolve this.

Pillow automation moved this from In progress to Closed May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Pillow
  
Closed
Development

Successfully merging a pull request may close this issue.

4 participants