2013.10.08 10:01 "[Tiff] Problem with reading tiff exported from GDAL in C", by Josef Olah

2013.10.08 11:39 "Re: [Tiff] Problem with reading tiff exported from GDAL in C", by Joris Van Damme

TIFF Directory at offset 0x14e588a (21911690)
    Image Width: 477 Image Length: 7643
    Bits/Sample: 16

  Sample Format: unsigned integer
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Extra Samples: 2<unspecified, unspecified>
  Samples/Pixel: 3
  Rows/Strip: 8
  Planar Configuration: separate image planes

I would guess that the number of extra samples == 2 is what causes TIFFReadRGBAImage to fail. What kind of extra samples is this?

The answer to that question, is the value of the ExtraSamples tag. Both extra samples are unspecified. That is a perfectly legit answer, it means there is no given naïeve interpretation, meaning the rendering or other interpretation of the channels is only known on an application-specific level. A main-stream rendering that does not contain this application-specific knowledge, should ignore the channels.

An alpha channel would be one extra sample per RGB triplet, not two.

If the alpha channel is not pre-multiplied, any number of alpha channels is allowed. A non-multiplied alpha channel is simply a mask, and it's perfectly legit to have multiple masks in a single image. Furthermore, "per RGB triplet" should say "per pixel", as multiple PhotometricInterpretations besides RGB exist.

Your best bet would probably be to directly read scanlines with TIFFReadScanline in the format you already know: it is 5 image planes

No, it is not. SamplesPerPixel is 3, confirmed by the fact that the PhotometricInterpretation implies a single channel and ExtraSamples implies 2 subsequent unspecified channels. Therefore, there are 3 'planes', not 5.

Best regards,

Joris Van Damme