Combining OpenEXRs

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
lapzerus

Combining OpenEXRs

Post by lapzerus »

I've been stuck trying to get this to work so hopefully some more seasoned users can help.

I have 2 OpenEXR files, one that is RGB and one that is just an alpha. I want to merge the two and make a single OpenEXR that is RGBA.

I'm stuck with the syntax, but any help would be appreciated.

Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combining OpenEXRs

Post by fmw42 »

lapzerus wrote:I've been stuck trying to get this to work so hopefully some more seasoned users can help.

I have 2 OpenEXR files, one that is RGB and one that is just an alpha. I want to merge the two and make a single OpenEXR that is RGBA.

I'm stuck with the syntax, but any help would be appreciated.

Thanks!
In general (but I cannot say about EXR format specifically), one adds a single channel to an rgb image as follows:

convert rgbimage alphaimage -alpha off -compose copy_opacity -composite rgbaimage

see http://www.imagemagick.org/Usage/compose/#copyopacity
lapzerus

Re: Combining OpenEXRs

Post by lapzerus »

Sorry I think I need to clarify,

I want to keep the original RGB image exactly the same, except I want the second EXR file that is just an alpha to be merged together to I have the original RGB plus the new alpha as a seperate channel.

The result of compositing my two test images right now with your method gives me a blank image.

Thanks for your help so far.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combining OpenEXRs

Post by fmw42 »

want to keep the original RGB image exactly the same, except I want the second EXR file that is just an alpha to be merged together to I have the original RGB plus the new alpha as a seperate channel.
Your two input images will not be changed. The resulting image will have 4 channels, r,g,b,a.

But as I said, I don't know how well IM handles EXR. What version of IM do you have? What Q level? What platform? Do you have the EXR delegate library installed?

The command I gave you is standard for combining a grayscale single channel as the alpha channel to an RGB image. But perhaps your IM version is too old for that compose method?

This command works very well for generating rgba PNG or TIF for example.

Note that as far as I know, IM only can handle EXR "half" format.
lapzerus

Re: Combining OpenEXRs

Post by lapzerus »

I grabbed the lastest source of IM and the Q level is set to 16. I grabbed the Openexr source too from www.openexr.com and compiled it all in VC2005 for windows platform.

My IM can open openexrs and write them, but I dont see them it under delegates.

Name Value
-------------------------------------------------------------------------------
NAME ImageMagick

Path: C:\ImageMagick-6.6.2\VisualMagick\bin\configure.xml

Name Value
-------------------------------------------------------------------------------
CC vs8
CC vs8
COPYRIGHT Copyright (C) 1999-2010 ImageMagick Studio LLC
COPYRIGHT Copyright (C) 1999-2010 ImageMagick Studio LLC
DELEGATES bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
DELEGATES bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
HOST windows-unknown-linux-gnu
HOST windows-unknown-linux-gnu
LIB_VERSION 0x662
LIB_VERSION 0x662
LIB_VERSION_NUMBER 6,6,2,0
LIB_VERSION_NUMBER 6,6,2,0
NAME ImageMagick
NAME ImageMagick
RELEASE_DATE 2010-06-01
RELEASE_DATE 2010-06-01
VERSION 6.6.2
VERSION 6.6.2
WEBSITE http://www.imagemagick.org
WEBSITE http://www.imagemagick.org
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combining OpenEXRs

Post by fmw42 »

Did you install the OpenEXR before installing IM?

Don't know about Windows, but on my Mac, my delegates looks like:

DELEGATES bzlib fftw fontconfig freetype gs jpeg jng jp2 lcms lqr mpeg openexr png rsvg tiff x11 xml zlib

IM 6.6.2.1 Q16 Mac OSX Tiger

Strange that all your lines are doubled?

Type:

convert -list configure

and look at the DELEGATES line.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combining OpenEXRs

Post by fmw42 »

This works for me:

convert logo: logo.exr
convert logo: -channel b -separate logob.exr
convert logo.exr logob.exr -alpha off -compose copy_opacity -composite logot.exr

IM 6.6.2.1 Q16 Mac OSX Tiger
mrtm3050
Posts: 11
Joined: 2010-06-25T08:20:50-07:00
Authentication code: 8675308

Re: Combining OpenEXRs

Post by mrtm3050 »

I'm having a similar problem. I can do operations on EXR files (convert, etc.) but I dont see it in my list of delegates.

Code: Select all

-----------------------------------------------------------------------
CC            vs8
CC            vs8
COPYRIGHT     Copyright (C) 1999-2010 ImageMagick Studio LLC
COPYRIGHT     Copyright (C) 1999-2010 ImageMagick Studio LLC
DELEGATES     bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
DELEGATES     bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
HOST          windows-unknown-linux-gnu
HOST          windows-unknown-linux-gnu
LIB_VERSION   0x662
LIB_VERSION   0x662
LIB_VERSION_NUMBER 6,6,2,7
LIB_VERSION_NUMBER 6,6,2,7
NAME          ImageMagick
NAME          ImageMagick
RELEASE_DATE  2010-07-15
RELEASE_DATE  2010-07-15
VERSION       6.6.2
VERSION       6.6.2
WEBSITE       http://www.imagemagick.org
WEBSITE       http://www.imagemagick.org
I compiled just fine. Linked to all the requisite openEXR libs and headers but still dont see anything. In the magic-conf file, I have added

Code: Select all

#define MAGICKCORE_OPENEXR_DELEGATE
I am having problems pertaining to using the magick++ api with openEXR. My demo application crashes when I try to read in a file with an EXR extension.

For ex:

Code: Select all

Image testEXR("testImage.exr");
breaks. Any ideas?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Combining OpenEXRs

Post by fmw42 »

If openexr is not in your delegates list, then I don't think IM recongnizes its existence. But I don't use windows and don't know the issues related to getting openexr working under Windows IM.
Post Reply