Skip to content

Commit

Permalink
fix: Add proxy support for EXR multipart output (AcademySoftwareFound…
Browse files Browse the repository at this point in the history
…ation#4263) (AcademySoftwareFoundation#4264)

Add proxy support for EXR multipart output by taking the setup code from
the other open() overload and calling the constructor accepting a stream
instead of a filename.


---------

Signed-off-by: Joachim Reichel <43646584+jreichel-nvidia@users.noreply.github.com>
  • Loading branch information
jreichel-nvidia authored and lgritz committed May 20, 2024
1 parent 15d30cb commit 34f8f1c
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/openexr.imageio/exroutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ OpenEXROutput::open(const std::string& name, const ImageSpec& userspec,
m_io = new Filesystem::IOFile(name, Filesystem::IOProxy::Write);
m_local_io.reset(m_io);
}
OIIO_ASSERT(m_io);
if (m_io->mode() != Filesystem::IOProxy::Write) {
// If the proxy couldn't be opened in write mode, try to
// return an error.
Expand Down Expand Up @@ -582,13 +581,20 @@ OpenEXROutput::open(const std::string& name, int subimages,

// Create an ImfMultiPartOutputFile
try {
// m_output_stream.reset (new OpenEXROutputStream (name.c_str())();
// m_output_multipart.reset (new Imf::MultiPartOutputFile (*m_output_stream,
// &m_headers[0], subimages)();
// FIXME: Oops, looks like OpenEXR 2.0 currently lacks a
// MultiPartOutputFile ctr that takes an OStream, so we can't
// do this quite yet.
m_output_multipart.reset(new Imf::MultiPartOutputFile(name.c_str(),
if (!m_io) {
m_io = new Filesystem::IOFile(name, Filesystem::IOProxy::Write);
m_local_io.reset(m_io);
}
if (m_io->mode() != Filesystem::IOProxy::Write) {
// If the proxy couldn't be opened in write mode, try to
// return an error.
std::string e = m_io->error();
errorfmt("Could not open \"{}\" ({})", name,
e.size() ? e : std::string("unknown error"));
return false;
}
m_output_stream.reset(new OpenEXROutputStream(name.c_str(), m_io));
m_output_multipart.reset(new Imf::MultiPartOutputFile(*m_output_stream,
&m_headers[0],
subimages));
} catch (const std::exception& e) {
Expand Down

0 comments on commit 34f8f1c

Please sign in to comment.