I believe this pull request implements the behaviors I describe: https://github.com/OpenImageIO/oiio/pull/512
When you pass a spec with .format==UNKNOWN, it will select a default data type. For file formats that support only one data type, it is that type; for OpenEXR, it's half; for FITS it's float; for DPX it's uint16; for everything else, it is uint8. On Feb 10, 2013, at 12:13 PM, Larry Gritz wrote: > On Jan 28, 2013, at 2:31 PM, Miles Bader wrote: > >> Second, a question: Is there a way I can tell OpenImageIO "whatever >> the output format is, use the 'normal' data-type for that format."? > > Good question. I think the honest answer is that we don't seem to have > implemented a consistent policy about what happens when a file is opened and > the ImageSpec requests a data type that is not supported by the file format. > Usually, it just picks a good fit among the supported data type. But not all > behave that way -- at least TIFF (I just checked) could outright reject > certain unsupported data types. And there isn't a way to say "give me the > default." > > So I propose the following rule, which if people approve I can implement in > no time: > > 1. ImageOutput::open will never fail because of a request for an unsupported > data type; if not supported, it will choose a supported data type that will > lose as little range or precision as possible compared to the original > request. The app, of course, is free to examine output->spec().format, > compare it to the original request, and take action if it couldn't get the > data format it originally requested. > > 2. If ImageOuput::open() is called with a spec whose format = > TypeDesc::UNKNOWN, the ImageOutput will select a "default" supported data > type, which is informally defined as "the most common configuration of that > file type in the real world, and/or the data type likely to have the widest > range of readers that are able to handle it." > > Sound good? > > -- lg > > -- > Larry Gritz > [email protected] > > > _______________________________________________ > 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
