2017.08.30 16:07 "[Tiff] problems saving BigTIFF format", by Paul Hemmer

2017.08.30 16:47 "Re: [Tiff] problems saving BigTIFF format", by Kemp Watson

Looks ok on a 5-second scanŠ

Some thoughts:

Does the software you¹re opening the image in support 16-bit 1 channel data (specifically in BigTIFF, not TIFF)?

You might try writing 3 channels as a test of this (faux-monochrome).

Does it support raster data? Quite a bit of software supporting very large images requiring BigTIFF also require tiles instead of raster/strip data.

W. Kemp Watson

kemp@objectivepathology.com

Objective Pathology Services Limited

8250 Lawson Road
Milton, Ontario
Canada L9T 5C6

www.objectivepathology.com
tel. +1 (416) 970-7284

Date: Wednesday, August 30, 2017 at 12:26 PM
To: Watson Kemp <kemp@objectivepathology.com>

Hi, thanks for the reply.

The file I write should be BigTIFF.

Below is how I write it (I've simplified some variables names for clarity.. This is 16bit grayscale data)

The same code below works fine for saving smaller images when I specify "w" instead of "w8"

But once I know my dataset is >4GB, I specify "w8" instead, otherwise its the same.

By the way, where can I find the latest official LibTIFF release that supports BigTIFF? I should be sure I'm using the right version. It seems there are a variety of links out there that point to old content and "page not found"

Thanks!

tif = TIFFOpen(l_thumb->filename, "w8");

TIFFSetField(tif, TIFFTAG_IMAGEWIDTH     , width        );
TIFFSetField(tif, TIFFTAG_IMAGELENGTH    , height       );
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE  , 16                    );
TIFFSetField(tif, TIFFTAG_COMPRESSION    , COMPRESSION_LZW       );
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC    , PHOTOMETRIC_MINISBLACK);
TIFFSetField(tif, TIFFTAG_FILLORDER      , FILLORDER_MSB2LSB     );
TIFFSetField(tif, TIFFTAG_ORIENTATION    , ORIENTATION_TOPLEFT   );
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1 );
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP , 8       );
TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT , RESUNIT_CENTIMETER    );
TIFFSetField(tif, TIFFTAG_XRESOLUTION    , pixels_per_cm);
TIFFSetField(tif, TIFFTAG_YRESOLUTION    , pixels_per_cm);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG   , PLANARCONFIG_CONTIG   );

tdata_t l_buffer;
unsigned long l_buffer_size = width*2; // LINE buffer for 16bit

l_buffer = _TIFFmalloc(l_buffer_size);

for (int row = 0; row < height; row++){ memcpy_s(l_buffer, l_buffer_size, &data[row*width], l_buffer_size);

int ret=TIFFWriteScanline(tif, l_buffer, row, 0);
if (ret==-1){
TIFFClose(tif);
return PACKET_TYPE_ERROR;
}
}

_TIFFfree(l_buffer);

TIFFClose(tif);

From: Kemp Watson <kemp@objectivepathology.com> Sent: Wednesday, August 30, 2017 12:17 PM

To: Paul Hemmer; tiff@lists.maptools.org

Is the file you are opening TIFF or BigTIFF? I.e how did you write it?

W. Kemp Watson

kemp@objectivepathology.com

Objective Pathology Services Limited

8250 Lawson Road
Milton, Ontario
Canada L9T 5C6

www.objectivepathology.com
tel. +1 (416) 970-7284

From: <tiff-bounces@lists.maptools.org> on behalf of Paul Hemmer <paulhemmer@hotmail.com>

Is anything other than specifying "w8" in TIFFOpen() required to successfully create a BigTIFF file?

When my dataset is < 4GB and I open with "w" and write the data, I can view the image just fine.

When it is > 4GB and I use "w8" to open, all else the same, then the resulting file cannot be opened by any of the image viewers I can find that are said to support BigTIFF (IMARIS, Nikon Elements, FIJI/BioFormats, and VeryLargeImageViewer)

Is there some other header fields I must add?

http