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

2008.08.08 08:53 "Re: [Tiff] Writing custom fields with big counts.", by Andy Cave

Hi Tom,

Are you doing anything wrong. Yes:

Why invent something non-standard, when TIFF provides the facility to do exactly what you want. You have two options:

  1. Put multiple images in a single file. Your main first image would be the RGB data that most applications will view and your second image would be your scientific data. This is all spec'd in the TIFF documentation -see page 16 to start with (Multiple Images per TIFF File) and then page 26 and later.
  2. Make your image an RGB image with extra samples (which are your scientific data), where these are marked as "unspecified". See page 31 for details on this.
  3. Personally, I'd go for the second option (assuming most readers work with it), as this keeps (preserves) your scientific data with the equivalent RGB data.
  4. Alternatively and even simpler, just create two TIFF files with similar names but one being slightly different to indicates it's the scientific data.

Regards,

Andy.

----- Original Message -----

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>