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

v3 tiff handling is not OME metadata friendly #953

Open
mlt opened this issue Mar 1, 2023 · 1 comment · May be fixed by #998
Open

v3 tiff handling is not OME metadata friendly #953

mlt opened this issue Mar 1, 2023 · 1 comment · May be fixed by #998

Comments

@mlt
Copy link

mlt commented Mar 1, 2023

This is a follow up on #914. Here is the code that breaks

import imageio.v3 as iio
import imageio.v2 as iio2
import numpy, tifffile
data = numpy.random.randint(0, 255, (256, 256, 3), 'uint8')
tifffile.imwrite('bug.tif', data, ome=True)
image_rgb = iio2.imread('bug.tif') # <- ok
meta = iio.immeta('bug.tif') # <- explodes

The last line causes the following traceback

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[8], line 4
      2 import imageio.v2 as iio2
      3 image_rgb = iio2.imread('bug.tif') # <- ok
----> 4 meta = iio.immeta('bug.tif') # <- explodes

File ~\miniconda3\envs\scikit-env\lib\site-packages\imageio\v3.py:250, in immeta(uri, index, plugin, extension, exclude_applied, **kwargs)
    247     call_kwargs["index"] = index
    249 with imopen(uri, "r", **plugin_kwargs) as img_file:
--> 250     metadata = img_file.metadata(**call_kwargs)
    252 return metadata

File ~\miniconda3\envs\scikit-env\lib\site-packages\imageio\plugins\tifffile_v3.py:307, in TifffilePlugin.metadata(self, index, page, exclude_applied)
    305                 metadata.update(flavor_metadata[0])
    306             else:
--> 307                 metadata.update(flavor_metadata)
    308 else:
    309     # tifffile may return a TiffFrame instead of a page
    310     target = target.keyframe

ValueError: dictionary update sequence element #0 has length 1; 2 is required
@FirefoxMetzger
Copy link
Contributor

Interesting find @mlt . Looking at the code, I can't say what could be the issue my guess is that we are probably not setting a flag correctly when reading OME.

Unfortunately, I have a bit of a backlog for ImageIO at the moment, so I can't say when I will have time to investigate this myself. However, if you want to have a go I can give you some guidance on where/how to look for the cause of the issue and then we can work on a fix together :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants