2008.08.08 05:15 "[Tiff] Writing custom fields with big counts.", by Tom Harris

2008.08.08 05:15 "[Tiff] Writing custom fields with big counts.", by Tom Harris

Greetings,

I am playing with an idea to add arbitrary extra fields to a vanilla RGB TIFF, these extra tags will hold the source image that was used to create the RGB image. I want to do this so tht I have data files from a scientific intrument that contain all sorts of strange data, but to the users look like normal multi-image 24 bit RGB files.

I can add the extra field OK, but I find that although the spec allows 4 bytes for the count, libtiff only seems to use 2 bytes, so the maximum count is 65535. The TIFFFieldInfo struct only uses shorts for field_readcount & field_writecount, so I suppose this is why. However, even if I have -1 for these values (indicating that the number of values is set in the call to TIFFSetField), the maximum count that I seem to be able to write is 65535. Tiffdump will only report the field count as correct if it is less than 32768, any more and it gives me a count of zero, even though inspecting a hex dump of the tiff file shows the correct count.

Am I doing something wrong?

I was hoping to save my private data as an array of 1024*1024*4 unsigned shorts, but it looks like this will not work with libtiff. Perhaps I should be looking at writing a table of offsets to data in strips (exactly how images are saved at present).

--

Tom Harris <celephicus(AT)gmail(DOT)com>