2010.09.08 18:00 "[Tiff] broken interface for TIFFTAG_SMINSAMPLEVALUE", by Olivier Paquet
I have recently tried to set and use TIFFTAG_SMINSAMPLEVALUE and
TIFFTAG_SMAXSAMPLEVALUE in an application and have come across a problem with the way they are presented in libtiff. The TIFF spec says this about the tags:
Type = the field type that best matches the sample data N = SamplesPerPixel
This field specifies the minimum sample value. Note that a value should be given for each data sample. That is, if the image has 3 SamplesPerPixel, 3 values must be specified.
libtiff chooses to handle data as double (converting from/to the required type on read/write of the directory) which is fine as it makes user code simpler. But libtiff also chooses to present the tag as having only a single value, replicating that value SamplesPerPixel times when writing the directory. This makes using the tag nearly impossible in my case as I need to set and retrieve the different values per sample.
I propose changing the interface so TIFFSetField/TIFFGetField deal with the tags as arrays. This would of course quietly break the interface for any application which uses libtiff to read/write these tags. For this reason, I'd put the change in libtiff4 only. Any objections? Or better ideas?