Page 1 of 1

How to save single channel EXR images with ImageMagick

Posted: 2016-12-15T23:10:08-07:00
by jasjuang
I have a 32 bit single channel EXR image that I want to crop using ImageMagick, the problem is after I crop it it got saved into 32 bit 3 channel image by ImageMagick.

Below are the attempts that I tried that didn't work

Code: Select all

mogrify -crop 200x100+238+200 test.exr -colorspace Y
This returns error mogrify: unrecognized image colorspace `Y'.

Code: Select all

mogrify -crop 200x100+238+200 test.exr -channel Y
This returns 32 bit 3 channel image.

Code: Select all

mogrify -crop 200x100+238+200 test.exr -separate 
This returns 8 bit 1 channel image.

I am on Ubuntu 16.04 and my version of ImageMagick is 6.9.6-4 Q32 x86_64.

How can I make ImageMagick to save my EXR file with the original single channel 32 bit format?

Re: How to save single channel EXR images with ImageMagick

Posted: 2016-12-16T00:50:05-07:00
by fmw42
Don't use mogrify. It is old and limited. Use convert. It may or not work, depending upon the library for EXR images

convert test.exr -crop 200x100+238+200 +repage result.exr

Re: How to save single channel EXR images with ImageMagick

Posted: 2016-12-16T09:49:10-07:00
by jasjuang
@fmw I ran your command and it still saves it as 3 channel image.

Re: How to save single channel EXR images with ImageMagick

Posted: 2016-12-16T10:10:48-07:00
by fmw42
Post your single channel (grayscale) EXR file to some place such as dropbox.com and put the URL here, so we can test with it.

Did you try:

Code: Select all

convert test.exr -crop 200x100+238+200 +repage -define exr:color-type=Y result.exr
See http://www.imagemagick.org/script/formats.php

EXR images often extend outside the normal range of values. Have you tried HDRI? See http://www.imagemagick.org/script/high- ... -range.php

I am not positive, but I thought IM only supported the EXR "half" format (16-bit).

Re: How to save single channel EXR images with ImageMagick

Posted: 2016-12-17T16:45:07-07:00
by jasjuang
@fmw42 I just tried your new command and it works! I think -define exr:color-type=Y does it. Thanks a lot for your help