1

I want to convert 16 bit (HALF) exr image into 32 bit exr image. I am trying to do it using ImageMagick built with openEXR, But I am not able to do the the same.

I have Build ImageMagick-7.0.8-23-Q8-windows-x64-static with HDRI flag enabled. I am using 16 bit RGBA EXR file . When I run below command:

identify -verbose "Desk.exr"

It gives Channel depth as 8 bit.

Format: EXR (High Dynamic-range (HDR))
Class: DirectClass
Geometry: 644x874+0+0
Units: Undefined
Colorspace: RGB
Type: TrueColorAlpha
Base type: Undefined
Endianess: Undefined
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Alpha: 1-bit

I tried to change it by using convert tool by specifying -depth 16 and 32, but it is still showing channel depth as 8 bit.

int main() {

Magick::InitializeMagick("");

Magick::Image image;
Magick::Image image2;
Magick::Image image3;
try {
     // Read a file into image object 
    image.read("D:\\IR\\EXR_Support\\Images\\Desk.exr");
            //Set bit to 32
    image.depth(32);
            image.channelDepth(MagickCore::RGBChannels,32);
            image.write("D:\\IR\\EXR_Support\\Images\\Desk_32Bits.exr");

    }
catch (Magick::Exception &error_)
{
    cout << "Caught exception: " << error_.what() << endl;
    return 1;
}
    return 0;

}

I checked channel depth of output file , that I have set 32 bit, but it is also showing :
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Alpha: 1-bit

I have built imagemagick with Quantum 8 bit and I am expecting it should work for 16 and 32 bit.

  • EXR store color data as float point values. Decoding them with a Q8 library version will introduce significant loss of precision. – emcconville Jan 28 '19 at 14:34

1 Answers1

1

The quantum depth, a.k.a. Q setting, is specified at compile time. You can't increase it at run-time.

If you want to process 32-bit images, you will need to re-compile with 32-bit quantum depth.

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Is there any way to compile generic version that will support 8 Bit, 16 Bit and 32 bit ? If I compile with 32 bit quantum depth it will unnecessarily hold extra space for 8 bit images. – Dhananjay Rohankar Jan 28 '19 at 13:00
  • 1
    AFAIK, the only generic version you could make would be a 32-bit version. I don't believe setting `depth` to `8` after loading an 8-bit image will save you any memory - I think it will still use 32-bits of storage (RAM) per sample. Maybe someone more knowledgeable than me will comment @fmw42 ? – Mark Setchell Jan 28 '19 at 13:08
  • If you use IM 7, it has HDRI enabled by default. With HDRI you can read and write to 32-bit files, if the format supports it. But Imagemagick may only support "half" (16-bit) files. I have no experience with that. – fmw42 Jan 28 '19 at 19:52
  • I tried with IM 7 to convert a 16-bit EXR file to 32-bits with `-define quantum:format=floating-point -depth 32`, but it shows only 16-bits afterwards. So it looks like IM only supports 16-bit format EXR. – fmw42 Jan 28 '19 at 20:00
  • I built IM with Q32 and now when I run *identify -verbose "Desk.exr"* it is giving depth as 32 Bit. It seems like IM is reading files with its build depth irrespective of file depth. even if I tried to convert this file to 16 bit using * convert -depth 16 * , it is still showing 32 BIt – Dhananjay Rohankar Jan 29 '19 at 11:25
  • Can you share the file `Desk.exr` somewhere please? – Mark Setchell Jan 29 '19 at 11:28
  • You can find it at [link] (https://github.com/openexr/openexr-images/tree/master/ScanLines) – Dhananjay Rohankar Jan 29 '19 at 13:05