Skip to content

Commit

Permalink
fix: Add proxy support for EXR multipart output (#4263) (#4264)
Browse files Browse the repository at this point in the history
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 May 16, 2024
1 parent feb58ac commit d868624
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 @@ -393,7 +393,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 @@ -573,13 +572,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 d868624

Please sign in to comment.