exr to jpg - ignore exr bounding box

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
mrCatfish
Posts: 6
Joined: 2019-05-08T08:59:09-07:00
Authentication code: 1152

exr to jpg - ignore exr bounding box

Post by mrCatfish »

Hi,

I am trying to convert exr images to jpeg. It works fine, but if the exr has a bounding box, the area outside the bounding box renders as white. I have tried both of these commands:

Code: Select all

# this is what I am using currently:
convert %s -flatten -alpha remove %s
# this is no good as it makes semi-transparent objects disappear
convert %s -background black -alpha remove -flatten %s
Sorry, can't see a way to attach an image...maybe because it's my first post?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: exr to jpg - ignore exr bounding box

Post by fmw42 »

This forum does not allow image upload. So you should upload your file to some free hosting service that won't change the format (or zip it first) and then put the URL here.
mrCatfish
Posts: 6
Joined: 2019-05-08T08:59:09-07:00
Authentication code: 1152

Re: exr to jpg - ignore exr bounding box

Post by mrCatfish »

Thanks fmw42. Here is a link to Google Drive where the original exr is and the jpeg derived from it.

https://drive.google.com/drive/folders/ ... sp=sharing
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: exr to jpg - ignore exr bounding box

Post by fmw42 »

Imagemagick does not see any bounding box. The alpha channel has a center black region and then at the top and bottom is white. That is why you get the white areas.

Your can see that by looking at the alpha channel and the underlying image:

Code: Select all

magick solarSystem.1116.exr -alpha extract alpha.png
magick solarSystem.1116.exr -alpha remove aoff.png
So you can either trim the white off in the output:

Code: Select all

magick solarSystem.1116.exr -background black -flatten \
-bordercolor white -border 1 -trim +repage -shave 1x1 \
solarSystem.1116.a.jpg
Or you can trim the white off in the alpha channel, then fill it out with black:

Code: Select all

magick solarSystem.1116.exr  \
\( -clone 0 -alpha extract -bordercolor white -border 1 \
-trim -background black -flatten -shave 1x1 \) \
-alpha off -compose copy_opacity -composite \
-background none -compose over -flatten \
solarSystem.1116.b.jpg
Or similarly, just trim the white off in the output and fill that back with black.
mrCatfish
Posts: 6
Joined: 2019-05-08T08:59:09-07:00
Authentication code: 1152

Re: exr to jpg - ignore exr bounding box

Post by mrCatfish »

Thanks for the reply.

Could this be a bug in imagemagick then? If I open the exr file in Nuke, I clearly see an alpha channel that is not a box... it is the round planet and its orbit. When I do "convert solarSystem.1116.exr -alpha extract alpha.png" I do see that it has constructed an alpha that is the boolean of the bounding box and the real alpha channel.

I have uploaded a new image to the Google drive with a screen grab showing Nuke displaying the original exr... there you can see the alpha channel with the exr bounding box as the dotted line.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: exr to jpg - ignore exr bounding box

Post by fmw42 »

That is a question for the IM developers. You could post your question about it being a bug to the Bugs forum or the Developers forum and put a link back to this topic.
mrCatfish
Posts: 6
Joined: 2019-05-08T08:59:09-07:00
Authentication code: 1152

Re: exr to jpg - ignore exr bounding box

Post by mrCatfish »

Post Reply