Multi-channel EXR support in command-line

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Posts: 1
Joined: 2019-06-26T06:57:57-07:00
Authentication code: 1152

Multi-channel EXR support in command-line

Post by mortenblaa »

I'm trying to extract/use specific channels from a multi-channel EXR, in order to save a specific render pass as a PNG.

Similar questions have been asked before, but they all date back 2 or more years.

I frequently use ImageMagick in a 3D animation pipeline to convert EXR files to other, smaller formats. Specifically using Pixar RenderMan to render the final images. These images most often contain multiple channels that are then composited to form the final image. However, they also include a so-called "beauty" pass, which is the combination of these channels/passes.

I have managed to render out EXR files that simple contains the "rgb" and "a" channels and these are converted to PNG without problems. Without the extra channels/passes, though.

Now, RenderMan technically refers to the "beauty" pass' channel as "Ci", and this seems to confuse ImageMagick, though it is RGB. So "Ci.R" etc. I could rename this to "rgb" instead of "Ci", which works, but breaks other tools like RenderMan's denoiser.

From what I can tell it isn't possible to tell ImageMagick to look for the "Ci" pass and use it as normal RGB.

I should note, that trying to open this image in Photoshop also just shows up black, so ImageMagick is not alone. However, Nuke correctly identifies the right channels. I don't know if the OpenEXR format somehow specifies which channels should be used as RGBA by default.

List of channels that should be present in the first sample file:

Code: Select all

Some sample images...

16-bit EXR straight from render with all passes: ... e.exr?dl=0
16-bit EXR with no AOVs (saved using Pixar "It" tool): ... s.exr?dl=0
16-bit EXR after denoising: ... d.exr?dl=0
8-bit PNG of what it should look like: ... s.png?dl=0

Code: Select all

Version: ImageMagick 7.0.8-49 Q16 x64 2019-06-08
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Visual C++: 180040629
Features: Cipher DPC HDRI Modules OpenMP(2.0)
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Multi-channel EXR support in command-line

Post by snibgo »

One ambition for IM V7 was the ability to read, process and write an arbitrary number of channels. But this has not happened.

exiftool can see the names of the many channels in sample_beauty_variance.exr, but has no ability (as far as I know) to rename the channels or to extract pixel data from arbitrary channels.
snibgo's IM pages:
User avatar
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Multi-channel EXR support in command-line

Post by magick »

The arbitrary channel infrastructure is in place in version 7 series of ImageMagick. We've been looking for use cases (and time) to add the finishing touches for fully-functional multi-channel image support. For convenience, we utilize the EXR delegate library ImfInputSetFrameBuffer() which only returns 4 channels @ RGBA. We'll need to revisit the EXR coder module to read all the image channels. If you have pointers to some example OpenEXR source code that reads all the channels of an EXR image, post the link here.
Post Reply