Unfortunately, an omission made it very hard to write a multi-subimage file 
(like an animated GIF) from the Python API, until a patch that just landed in 
the last week. So at the very least, you'd need to do a fresh OIIO build from 
the current top of master. It's not rocket science, but it's still going to be 
(even with the new release) 10-20 lines of Python to do it right. That oiiotool 
command line does all the tricks for you automatically.

        -- lg


> On Jul 17, 2020, at 1:48 PM, Jerome Raim <[email protected]> wrote:
> 
> Larry,
> I appreciate your quick response!
> 
> I was hoping to keep it all native-Python and not have to spit out temporary 
> files. 
> 
> CLI is definitely an easy option, so I could run it as a subprocess in my 
> python script. 
> 
> Best,
> Jerome
> 
> On Fri, Jul 17, 2020 at 4:37 PM Larry Gritz <[email protected] 
> <mailto:[email protected]>> wrote:
> You're half way there -- this python script splits all the non-RGB channels 
> out into separate JPG files.
> 
> It's easy to convert your jpegs to an animated GIF from the command line:
> 
>     oiiotool *.jpg -siappendall --attrib FramesPerSecond 1.0 -o anim.gif
> 
> Doing it from Python is possible (given a very recently posted fix), but 
> frankly is unnecessarily complicated compared to the above single command.
> 
> 
> 
>> On Jul 17, 2020, at 1:30 PM, Jerome Raim <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Hello all,
>> I'm writing a script to help operators inspect all available channels that 
>> aren't RGB in an EXR. I'd like to create a 1fps GIF that shows all non-RGB 
>> channels.
>> 
>> I am able to extract each channel and save it as JPG, but not finding the 
>> proper syntax to save it as an animated GIF.
>> 
>> What I have so far:
>> 
>> import OpenImageIO as oiio
>> from OpenImageIO import ImageInput, ImageOutput
>> from OpenImageIO import ImageBuf, ImageSpec, ImageBufAlgo, ROI
>> 
>> input_path = 'vfx.exr'
>>  
>> 
>> img = oiio.ImageBuf(input_path)
>> 
>> for ch in [c for c in spec.channelnames if not c in ['R', 'G', 'B']]:
>>     ch_img = ImageBufAlgo.channels(img, (ch,ch,ch), newchannelnames=("R", 
>> "G", "B"))
>>     ch_img = ImageBufAlgo.fit(ch_img, roi=ROI(0,640,0,480,0,1,0,3))
>>     ImageBufAlgo.render_text(ch_img, x=0, y=100, text=ch, 
>> textcolor=(1,1,1,1))
>>     
>>     ch_img.write("{}.jpg".format(ch) ## 
>> 
>> 
>> Thanks in advance for your help.
>> 
>> Best,
>> Jerome
>> _______________________________________________
>> Oiio-dev mailing list
>> [email protected] <mailto:[email protected]>
>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org 
>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
> 
> --
> Larry Gritz
> [email protected] <mailto:[email protected]>
> 
> 
> 
> 
> _______________________________________________
> Oiio-dev mailing list
> [email protected] <mailto:[email protected]>
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org 
> <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

Reply via email to