2019.12.09 20:19 "[Tiff] help writing RGB TIFF", by Paul Hemmer

2019.12.09 21:40 "Re: [Tiff] help writing RGB TIFF", by Paul Hemmer

I'm sorry, I only told you the version of LibTIFF, not the APIs I use

Yes, I set tags first.

I use these calls in this order:

TIFF* tiff_handle = TIFFOpen(filename.c_str(), "w");

TIFFSetField(tiff_handle, .....) // as described in first post

for each 256x256 tile (each tile "oTile" is an OpenCV Mat of type CV_8UC3)
     TIFFWriteTile(tiff_handle, oTile.data, tile_posx, tile_posy, 0,0);

TIFFClose(tiff_handle)

I don't have GraphicsMagick installed, but I do have a copy of ImageMagick IMDisplay v1.0 installed. It opens and displays just fine, nothing to indicate it's 3 distinct channels.

Could the issue be due to the tiled nature of the TIFF I generate and how ImageJ handles it? (It's acutally the ImageJ "Bio-Formats" Importer, as ImageJ won't natively open a tiled-tiff)

If in ImageJ I choose "convert to RGB" and re-save it, it is no longer tiled and tiffdump changes to:

imagej_saved.tif:
Magic: 0x4d4d <big-endian> Version: 0x2a <ClassicTIFF>
Directory 0: offset 8 (0x8) next 0 (0)
SubFileType (254) LONG (4) 1<0>
ImageWidth (256) LONG (4) 1<12288>
ImageLength (257) LONG (4) 1<6144>
BitsPerSample (258) SHORT (3) 3<8 8 8>
Photometric (262) SHORT (3) 1<2>

ImageDescription (270) ASCII (2) 26<ImageJ=1.51a\nunit=micron ...>

StripOffsets (273) LONG (4) 1<2050>
SamplesPerPixel (277) SHORT (3) 1<3>
RowsPerStrip (278) SHORT (3) 1<6144>
StripByteCounts (279) LONG (4) 1<226492416>

XResolution (282) RATIONAL (5) 1<2.048>
YResolution (283) RATIONAL (5) 1<2.048>

ResolutionUnit (296) SHORT (3) 1<1>
50838 (0xc696) LONG (4) 2<12 1788>
50839 (0xc697) BYTE (1) 1800<0x49 0x4a 0x49 0x4a 0x69 0x6e 0x66 0x6f 00 00 00 0x1 00 0x20 00 0x42 00 0x69 00 0x74 00 0x73 00 0x50 ...>

________________________________
From: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
Sent: Monday, December 9, 2019 4:31 PM

To: Paul Hemmer <paulhemmer@hotmail.com>
Cc: Tiff List <tiff@lists.osgeo.org>
Subject: Re: [Tiff] help writing RGB TIFF

What libtiff APIs are you using to write your file?

You did not answer this one of my three questions.

Are you setting these tags before calling functions to output your data?

If you are able to install GraphicsMagick, what does GraphicsMagick think about your file?

Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt