Wrting tiff image with bit depth of 32 or 64

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
jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Wrting tiff image with bit depth of 32 or 64

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

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

Post by jsanterre »

Ah! That's what I was afraid of... Thank you so much for your quick answer!

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

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

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Well I guess I was wrong, also. I never knew that define worked without HDRI, also.
jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

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

Post 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
Post Reply