Compositing Issue with Canvas and EXRs

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
nate101
Posts: 9
Joined: 2017-05-24T04:29:54-07:00
Authentication code: 1151

Compositing Issue with Canvas and EXRs

Post by nate101 »

Hi,

Thanks everyone in advance, I'm a noobish Imagemagick user so the answer is probably obvious but for the life of me I cannot figure out what I'm doing wrong here:

- I'm using ImageMagick 7.0.8-Q16-HDRI
- I'm trying to create a composite image that combines an ImageMagick-created canvas with 32-bit exr's from another software package
- The goal here is to do the following:

A. Create a solid black canvas in Imagemagick
B. Create a solid green canvas on top of with a 32-bit EXR (Alpha.exr) as a mask (creating appearance of a green circle on black background)
C. Layer on another 32-bit EXR (Shading.exr) using multiply method that gives the impression that the circle is a 3-dimensional sphere
D. The desired output is a 3-dimensional green sphere on a black background, in JPG format


- When I break this process into two separate commands I get the correct output, but when I try to do it all in one command I get a different/incorrect output
- For example, it works properly when I do this: A + B = AB and AB + C = D
- But for some reason it fails when I do this all in one command: A + B + C <> D

Here are the two EXRs:

http://www.configyur.com/testArea/ballS ... /Alpha.exr
http://www.configyur.com/testArea/ballS ... hading.exr

And here is the code as two separate commands with an intermediate EXR output (Step1.exr):

Code: Select all

magick ( -size 300x169 xc:rgb(0,0,0) -depth 32 ) ( -size 300x169 xc:rgb(28,104,76) -depth 32 ) Alpha.exr -composite -depth 32 Step1.exr

Code: Select all

magick Step1.exr Shading.exr -compose multiply -composite Output1.jpg

And here is the way I tried to combine everything into one command:

Code: Select all

magick ( ( -size 300x169 xc:rgb(0,0,0) -depth 32 ) ( -size 300x169 xc:rgb(28,104,76) -depth 32 ) Alpha.exr -composite -depth 32 ) Shading.exr -compose multiply -composite Output2.jpg
The problem is the first two commands above produce this,the correct output:

Image

And the third consolidated command produces this, the incorrect output:

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

Re: Compositing Issue with Canvas and EXRs

Post by fmw42 »

Add +swap before the -compose multiply. IM uses the first image in the sequence to define certain properties.

magick ( ( -size 300x169 xc:rgb(0,0,0) -depth 32 ) ( -size 300x169 xc:rgb(28,104,76) -depth 32 ) Alpha.exr -composite -depth 32 ) Shading.exr +swap -compose multiply -composite Output2.jpg

It does not matter if you specify -depth 32. That can be removed everywhere with no ill effects since you are using HDRI compile. Further more, ImageMagick can only create 16-bit ("half" format) exr files.
nate101
Posts: 9
Joined: 2017-05-24T04:29:54-07:00
Authentication code: 1151

Re: Compositing Issue with Canvas and EXRs

Post by nate101 »

Fred,

Thanks so much, I could have tinkered with this for hours and never come up with that. Always appreciate your quick responses!
Post Reply