Skip to content

Iteration/Volume support for paths #619

Closed

Description

@FirefoxMetzger

The current API offers mimread/mvolread and the new API will offer iter as ways to read multiple images from containers that store more than a single image.

I was wondering if it would make sense to expand this functionality to paths and treat them as a container, i.e., mimread("some/path") will return a list of all the images inside the given path. Whether or not this should be recursive we can discuss.

On the same token, mimread("some/file.zip") can allow reading multiple files from a zip-compressed file which could significantly decrease loading time if we operate on multiple images. I could simply zip my dataset and trivially enjoy the benefits of compressed IO while having imageIO inflate the file(s) on-demand.

Activity

  1. almarklein commented on Apr 6, 2021

    @almarklein
    Member

    mimread("some/path")

    I feel this should not be in the scope of imageio. This is easily solved with from fname in os.listdir(path): imagio.imread(fname). There are also potentially different plugins involved, which can all fail in their own way.

    mimread("some/file.zip")

    I can see the advantage, but still think it's out of scope. It's still a rather specific use-case which can become complex quickly. Let's avoid feature creep. I'd much rather add an example to our docs that demonstrates how to implement this:

    import os
    import zipfile
    import imageio
    
    def read_images_from_zipfile(filename):
        zf = zipfile.ZipFile(filename)
        images = []    
        for item in zf.filelist:
            ext = os.path.splitext(item.filename)[1]
            f = zf.open(item.filename)
            im = imageio.imread(f, format=ext)
            images.append(im)
        return images
  2. FirefoxMetzger commented on Apr 6, 2021

    @FirefoxMetzger
    ContributorAuthor

    Fair enough. This would sound like a nice first issue; I'll update the tags.

    This could make a great "good-first-issue". How come we don't have this label?

  3. almarklein commented on Apr 7, 2021

    @almarklein
    Member

    I think new GH repos have this by default, but not at the time that this repo was created.

  4. almarklein commented on Apr 7, 2021

    @almarklein
    Member

    I jusr created that label and assigned it to this issue.

  5. linked a pull request that will close this issueModernizing the docs #648on Jun 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions