Yes, just keep reading seek_subimage() to read MIP levels for each subimage, and successive subimages. If seek_subimage(s,m) fails, it means that m-1 was the last MIP level fo subimage s. This also means that if seek_subimage(s,1) fails, then subimage s is not MIP-mapped at all. If seek_subimage(s,0) fails, it means that s-1 was the last subimage in the file.
If you use ImageBuffer.nsubimages(), its implementation will have to do the above anyway (for many formats, at least), which means you might end up traversing the image file twice -- once just to find out how many subimages there were in total, and then again to read them. It's more efficient to just read them sequentially once, stopping when seek_subimage tells you there is nothing more to read. > On Feb 8, 2021, at 12:29 AM, Liam <lcol...@gmail.com> wrote: > > Hello and thanks for the clear answer. > My work is targeted at the CGI industry so I will need to take this kind of > format in account. > > Would you recommend to first use an "ImageBuffer" with .".nsubimages()" to > determine if the image need to have its subimages/miplevel processed and then > use "ImageInput". > OR just use "ImageInput" at first and just with "_seek_subimage()" see if > there is multiple subimages/miplevel ? > > Cheers. > Liam. > > Le dim. 7 févr. 2021 à 23:06, <oiio-dev-requ...@lists.openimageio.org > <mailto:oiio-dev-requ...@lists.openimageio.org>> a écrit : > Send Oiio-dev mailing list submissions to > oiio-dev@lists.openimageio.org <mailto:oiio-dev@lists.openimageio.org> > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org > <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org> > or, via email, send a message with subject or body 'help' to > oiio-dev-requ...@lists.openimageio.org > <mailto:oiio-dev-requ...@lists.openimageio.org> > > You can reach the person managing the list at > oiio-dev-ow...@lists.openimageio.org > <mailto:oiio-dev-ow...@lists.openimageio.org> > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Oiio-dev digest..." > > > Today's Topics: > > 1. SubImage and MipLevel (Liam) > 2. Re: SubImage and MipLevel (Larry Gritz) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 7 Feb 2021 17:53:13 +0100 > From: Liam <lcol...@gmail.com <mailto:lcol...@gmail.com>> > To: "oiio-dev@lists.openimageio.org <mailto:oiio-dev@lists.openimageio.org>" > <oiio-dev@lists.openimageio.org <mailto:oiio-dev@lists.openimageio.org>> > Subject: [Oiio-dev] SubImage and MipLevel > Message-ID: <dd5af729-0353-4855-87cc-c9b0db1fc...@hxcore.ol> > Content-Type: text/plain; charset="us-ascii" > > An HTML attachment was scrubbed... > URL: > <http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/attachments/20210207/66da84e6/attachment-0001.html > > <http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/attachments/20210207/66da84e6/attachment-0001.html>> > > ------------------------------ > > Message: 2 > Date: Sun, 7 Feb 2021 10:32:53 -0800 > From: Larry Gritz <l...@larrygritz.com <mailto:l...@larrygritz.com>> > To: OpenImageIO dev list <oiio-dev@lists.openimageio.org > <mailto:oiio-dev@lists.openimageio.org>> > Subject: Re: [Oiio-dev] SubImage and MipLevel > Message-ID: <73e1ab98-ce17-42ea-b738-0d7ce44be...@larrygritz.com > <mailto:73e1ab98-ce17-42ea-b738-0d7ce44be...@larrygritz.com>> > Content-Type: text/plain; charset="utf-8" > > Yes, a file can have both. They are not just different words for the same > thing. Subimages means that there are multiple, completely different images > in one file container (which may have different channel sets, totally > different metadata, etc). MIPmapping means that a (sub)image has multiple > copies of the image at a series of different resolutions (but that's the only > way that they'll differ). Each subimage can potentially be MIPmapped or not, > independently of all the other subimages. > > One example is "multi-part" OpenEXR files -- each "part" is what OIIO calls a > subimage, and they may be MIPmapped. > > Another example is Disney's PTex format -- the texture for each geometric > face is a subimage, and of course they are MIPmapped. > > That said, most image formats don't support either subimages or MIPmapping, > let alone both. So whether you need to care about it depends on the range of > file formats you might encounter. If you're writing a web photo processing > app that only will ever JPEG and PNG as input, say, then maybe you don't need > the complexity of handling more than one single image in a file. > > > > On Feb 7, 2021, at 8:53 AM, Liam <lcol...@gmail.com > > <mailto:lcol...@gmail.com>> wrote: > > > > Hello, > > I am using the OIIO python bindings and I had a simple question: > > > > Can a file have multiple subimages AND multiples miplevel ? > > Or maybe each subimage can have multiple miplevels ? > > > > Or do I only need to care for one ? for example if I read an Image and see > > multiple miplevels I assume that I don?t need to care about processing > > subimages. > > > > Cheers. > > Liam Collod. > > -- > Larry Gritz > l...@larrygritz.com <mailto:l...@larrygritz.com> > > > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > <http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/attachments/20210207/8d9a7765/attachment-0001.html > > <http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/attachments/20210207/8d9a7765/attachment-0001.html>> > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Oiio-dev mailing list > Oiio-dev@lists.openimageio.org <mailto:Oiio-dev@lists.openimageio.org> > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org > <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org> > > > ------------------------------ > > End of Oiio-dev Digest, Vol 149, Issue 4 > **************************************** > _______________________________________________ > Oiio-dev mailing list > Oiio-dev@lists.openimageio.org > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org -- Larry Gritz l...@larrygritz.com
_______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org