
Thread
2017.01.05 19:30 "[Tiff] photometric value different when get from TIFF tag or from a TIFFRGBAImage", by Vincent Torri
Hello
I have attached a small test program which displays the photometric
value of an attached TIFF file
from TIFFRGBAImage: value is 2
from TIFF tag, value is 32845
from TIFFPrintDirectory() (which uses TIFF flag ?) it is also 32845
Is it normal or is it a bug?
which value should I choose in case there is no bug?
TIFF file is from ghostscript source code
thank you
Vincent Torri
#include <stdio.h>
#include <tiff.h>
#include <tiffio.h>
int main(int argc, char *argv[])
{
TIFF *t;
int i;
if (argc < 2)
{
fprintf(stderr, "Usage: %s file.tif\n", argv[0]);
return -1;
}
t = TIFFOpen(argv[1], "r");
if (!t)
{
fprintf(stderr, "can not open %s\n", argv[1]);
return -1;
}
i = 0;
do
{
TIFFRGBAImage img;
char err[1024];
if (TIFFRGBAImageBegin(&img, t, 0, err))
{
unsigned short val;
/*
* TODO
* TIFFTAG_COLORMAP
*/
fprintf(stderr, " Structure\n");
fprintf(stderr, " photometric: %d\n\n", img.photometric);
fprintf(stderr, " TIFF Tags\n");
fprintf(stderr, " photometric: ");
if (TIFFGetField(t, TIFFTAG_PHOTOMETRIC, &val))
fprintf(stderr, "%d", val);
fprintf(stderr, "\n\n");
}
else
TIFFError(argv[1], err);
TIFFPrintDirectory(t, stderr, 0);
fprintf(stderr, "\n");
i++;
} while (TIFFReadDirectory(t));
fprintf(stderr, "%d directories in %s\n",i, argv[1]);
TIFFClose(t);
return 0;
}