Page 1 of 1

Wrting tiff image with bit depth of 32 or 64

Posted: 2015-04-29T06:04:29-07:00
by jsanterre
Hi,

I'm using Magick++ (Q16) on Windows 7. I would like to find a way to write tiff image with bit depth of 32 or even 64. Here's a portion of my C++ code:

Magick::Image m_image;
m_image.type( Magick::TrueColorMatteType );
m_image.fileName( filename );
m_image.depth( bitDepth );
m_image.defineValue( "quantum", "format", "floating-point" );

For a filename having a .tiff extension and a bitDepth of 32 or 64, I would expect IM to write a tiff image with a bit depth of 32 or a 64. Am I doing something wrong? To verify my results, I'm using ImageMagick identify from the command line and I'm always getting something like:

bird_32.tiff TIFF 1280x1024 1280x1024+0+0 16-bit sRGB 10.49MB 0.000u 0:00.000

so I suppose that means my tiff image bit depth is still 16. Is there something I'm not getting? I have been reading many posts on this forum but none address this directly (that I'm aware of...).

Thank you very much!

Julie

Re: Wrting tiff image with bit depth of 32 or 64

Posted: 2015-04-29T06:40:33-07:00
by snibgo
jsanterre wrote:I'm using Magick++ (Q16) on Windows 7.
Q16 IM can't write Q32 or Q64 files. You should re-compile IM with the larger Q number, as well as HDRI.

Re: Wrting tiff image with bit depth of 32 or 64

Posted: 2015-04-29T06:44:23-07:00
by jsanterre
Ah! That's what I was afraid of... Thank you so much for your quick answer!

Julie

Re: Wrting tiff image with bit depth of 32 or 64

Posted: 2015-04-29T09:07:05-07:00
by fmw42
In Q16 HDRI you can do it, but you must also use a define when writing tiff. See the tiff section of http://www.imagemagick.org/script/formats.php#supported

"To specify a single-precision floating-point format, use -define quantum:format=floating-point. Set the depth to 64 for a double-precision floating-point format."

Or on http://www.imagemagick.org/script/comma ... php#define

Re: Wrting tiff image with bit depth of 32 or 64

Posted: 2015-04-29T09:30:19-07:00
by snibgo
Thanks for the correction, Fred. I was wrong. For example, with Q16:

Code: Select all

f:\web\im>%IM%convert -size 1x100000 gradient:red-blue -compress None -depth 32 -define quantum:format=floating-point x.tiff

f:\web\im>%IM%identify x.tiff
x.tiff TIFF 1x100000 1x100000+0+0 32-bit sRGB 1.202MB 0.000u 0:00.000

Re: Wrting tiff image with bit depth of 32 or 64

Posted: 2015-04-29T09:34:58-07:00
by fmw42
Well I guess I was wrong, also. I never knew that define worked without HDRI, also.

Re: Wrting tiff image with bit depth of 32 or 64

Posted: 2015-05-08T09:41:48-07:00
by jsanterre
Hi!

I'm very happy to hear that it is in fact possible to write 32-bit tiff images. That's awesome. I'm sorry for my late answer -- I forgot to subscribe to this topic...

I was in fact able to write a 32-bit tiff file from the command line using the command snibgo posted earlier. But unfortunately, I'm still unable to do the same from C++ (with Magick++ API) using the code I posted earlier. I also inverted the order of two statements like that:

Code: Select all

Magick::Image m_image;
m_image.type( Magick::TrueColorMatteType );
m_image.fileName( filename );
m_image.defineValue( "quantum", "format", "floating-point" );
m_image.depth( bitDepth ); 
with no success. Furthermore, I tried the following:

Code: Select all

Magick::Image m_image;
m_image.type( Magick::TrueColorMatteType );
m_image.fileName( filename );
m_image.defineValue( "quantum", "format", "floating-point" );
m_image.depth( 32 ); 
std::cout << DEBUG: " << m_image.depth() << std::cout; 
and I'm getting "DEBUG: 16" as output. It's like m_image.depth() can't be set to 32? Maybe there's something wrong with the way I use defineValue()...

Thank you very much for your help!

Julie