question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

imageio v3 api reads all pages of a multipage TIFF at once

See original GitHub issue

I have a two-page TIFF, one 8bit grayscale image of shape (15,10) per page, and I am expecting imageio.v3.imiter to iterate over the two pages. Yet, it reads them both at once:

>>> from skimage import data_dir
>>> file = data_dir + '/multipage.tif'
>>> import imageio
>>> len([*imageio.v3.imiter(file)])
1
>>> for img in imageio.v3.imiter(file):
...     img.shape
... 
(2, 15, 10)

The same code prior to #805 fulfills my expectation and iterates over the two pages:

>>> from skimage import data_dir
>>> file = data_dir + '/multipage.tif'
>>> import imageio
>>> len([*imageio.v3.imiter(file)])
2
>>> for img in imageio.v3.imiter(file):
...     img.shape
... 
(15, 10)
(15, 10)

The TIFF file in question is part of skimage: https://github.com/scikit-image/scikit-image/blob/c95a8fd46a49a38de1f6032c84d9d61160b78283/skimage/data/multipage.tif It appears to have been created with ImageMagick.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
almarkleincommented, Jun 8, 2022

@FirefoxMetzger good luck with your thesis!! 😃

0reactions
lschrcommented, Nov 30, 2022

@FirefoxMetzger Thanks for the reply!

So the expected result should be that you get one ndimage instead of a sequence of frames.

I guess you are right. However, since contiguous=True used to be the default (and I wasn’t even aware of this option), I have now a lot of old files with all images in a single series, and I guess I am not the only one. This was just one example illustrating why I find it useful to be able to read individual pages. The other, more concerning one is commercial software over which we have no control writing all images into a single series.

The short answer is unfortunately no because we are moving away from the image modes iIvV?

I wasn’t thinking about permanently reverting #816, but only until there is another way to load single pages (i.e., #914 is merged). I really appreciate your work moving imageio forward!

if you want to test this early, feel free to have a look at the PR 😃 I can’t give an exact PR because I am juggling a few things in parallel right now, but I promise to incorporate feedback before it gets merged 😉

Cool, I will have a look.

Read more comments on GitHub >

github_iconTop Results From Across the Web

imageio v3 api fails to read all frames in a MetaMorph stk file · Issue ...
FWIW, STK files are not regular TIFF. They store "frames" not in separate TIFF pages but contiguously after the image data of the...
Read more >
Core API v3 — imageio 2.22.4 documentation
This API provides a functional interface to all of ImageIOs backends. ... Useful if the format supports storing more than one (GIF, multi-page...
Read more >
Writing multipage TIFF with Python
An easy, robust way to write multipage TIFF on any platform in Python is imageio. For all examples below, assume a stack of...
Read more >
Splitting a multipage TIFF image into individual images (Java)
You can use the Java Advanced Imaging library, JAI, to split a mutlipage TIFF, by using an ImageReader: ImageInputStream is = ImageIO.
Read more >
imageio Documentation - Read the Docs
import imageio.v3 as iio. # index=None means: read all images in the file and stack along first axis frames = iio.imread("imageio:newtonscradle.gif", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found