So I have to actually copy the pixels from all the subimages?  I can't
simply inject the metadata in place?  That's just very expensive when I
have 50 parts and it uses a lot of ram and can be slow.


> But there's something you do need to be careful about, which is that not
> all image formats allow arbitrary metadata to be per-subimage. For EXR in
> particular, there are some things that are allowed to vary between parts,
> and other things that are not. It isn't a fully general container of
> arbitrary images in one file.


For our renders we only want to inject our maya scene metadata into part 0
(rgba).  We don't want to duplicate the same data across all parts if
possible.

On Thu, Nov 16, 2017 at 11:01 AM, Larry Gritz <[email protected]> wrote:

> Right. The gist is that you have to read the input subimage by subimage,
> writing to the output as you go, something like this (pseudocode):
>
>     open input file
>     create output file
>     while True :
>         read image from input (including spec)
>         break if the read failed because we've run out of subimages
>         alter spec to add metadata, if you want at this subimage
>         if this is the first subimage,
>             open output with the Create mode flag (and altered spec)
>         else
>             open output with the AppendSubimage mode flag (and altered
> spec)
>         write the output image
>         input.seek_subimage to the next subimage
>         break if seek_subimage failed because we're out of subimages
>     close the files
>
>
> But there's something you do need to be careful about, which is that not
> all image formats allow arbitrary metadata to be per-subimage. For EXR in
> particular, there are some things that are allowed to vary between parts,
> and other things that are not. It isn't a fully general container of
> arbitrary images in one file.
>
>
> On Nov 16, 2017, at 10:51 AM, Andrew Gartner <[email protected]>
> wrote:
>
> Hey Deke,
>
> I don't have the exact code handy, but I've managed to do this a few
> times. If memory serves you just need to create imagespecs for each part
> with the proper metadata you want per-part and use the oiio.AppendSubimage
> with ImageOutput after calling open().
>
>
> outFile = foo.exr
> specs = tuple(...all your image specs with metadata...)
> output = ImageOutput.open(outFile, specsTuple)
> for part in range(1,len(parts)):
>     output.open(outFile, outSpecs[part]. oiio.AppendSubimage)
>    ....write image/scanlines with your data and the correct index to the
> image spec not sure if you ahve to do a full re-read from the source
> image....
>
> Hope that helps get you started, if someone else doesn't have exact code.
>
> ~Andrew
>
> On Thu, Nov 16, 2017 at 10:02 AM, Deke Kincaid <[email protected]>
> wrote:
>
>> Hi Folks
>>
>> Does anyone have an example of how to inject metadata with the oiio
>> python bindings into a specific part of a multipart EXR?(part 0 for
>> example)  We keep trying to do this but the output is that all my parts
>> disappear and I only have a part 0 in my output image.
>>
>> _______________________________________________
>> Oiio-dev mailing list
>> [email protected]
>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>>
>>
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>
>
> --
> Larry Gritz
> [email protected]
>
>
>
>
>
> _______________________________________________
> Oiio-dev mailing list
> [email protected]
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
>
>
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to