AWare Systems, Home TIFF and LibTiff Mail List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
January 2019

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date


The TIFF Mailing List Homepage
Archive maintained by AWare Systems

New Datamatrix section

Valid HTML 4.01!

2019.01.22 15:14 "[Tiff] Unable to write inkName - libTiff 4.0.9", by SM


I am trying a small code snippet, with libTIFF 4.0.9, which is trying to
write the InkNames tag in a separated image but I am hitting the following

TIFFSetField: test.tif: Invalid InkNames value; expecting 4 names, found 3.

I have attached the standalone code to this email. Please note that I have
set the EXTRASAMPLES tag so I believe I can set the rest 3 values that can
be used with SamplesPerPixel.

Can you please confirm if it is a bug?

Also, I noted that the documentation page mentions that "The number of
strings must be equal to NumberOfInks":

But I found that I can set any value for the tag TIFFTAG_NUMBEROFINKS and
code would still work.



#include <tiffio.h>

int main()

const char *ink_names = "Red\0Green\0Blue\0";
const int ink_names_size = 15;
printf("Entering main()\n");
TIFF *out=TIFFOpen("test.tif", "w");
int status;

status = TIFFSetField(out, TIFFTAG_IMAGEWIDTH, 10); // set the width of the image printf("Status = %d\n", status);

status = TIFFSetField(out, TIFFTAG_IMAGELENGTH, 7); // set the height of the image printf("Status = %d\n", status);

status = TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 4); // set number of channels per pixel printf("Status = %d\n", status);

status = TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); // set the size of the channels printf("Status = %d\n", status);

status = TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_NONE); printf("Status = %d\n", status);

status = TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 2); printf("Status = %d\n", status);

status = TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); printf("Status = %d\n", status);

status = TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_SEPARATED); // Separated image printf("Status = %d\n", status);

uint16 extra[1];

status = TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, &extra); // Extrasample is Unspecified printf("Status = %d\n", status);

TIFFSetField(out, TIFFTAG_NUMBEROFINKS, 3); status = TIFFSetField(out, TIFFTAG_INKNAMES, ink_names_size, ink_names); printf("Status = %d\n", status);

        printf("Exiting main()\n");