2022.07.28 17:54 "[Tiff] Strange behavior for the PlanarConfiguration tag in write mode", by Maged Rifaat
Hello everybody,
I noticed a strange behavior when trying to read the default value of the PlanarConfiguration tag when trying to create a new Tiff file using LibTIFF. When I try running the following code:
TIFF *tif = TIFFOpen("test.tif", "w");
unsigned short planar;
TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planar);
printf("Default Planar value = %d\n", planar);
I get a value of 0 for the planar configuration although the standard specified that the default value is 1 not 0. Also if I try to write to this new Image:
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 1);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, 1);
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
unsigned char pixel[3] = {255, 255, 255};
TIFFWriteEncodedStrip(tif, 0, pixel, 3);
TIFFClose(tif);
I get an error message:
TIFFWriteEncodedStrip: Must set "PlanarConfiguration" before writing data.
Although the standard specifies that the PlanarConfiguration tag is not required.
If the image is opened for reading, however, the default value is 1 even if it doesn't exist in the image which is the expected behavior, so is this a bug or this behavior necessary and if so, what is the reason behind this?
Best Regards
Maged