Tiff image without TIFFTAG_PHOTOMETRIC won't load
Posted: 2019-08-21T19:24:53-07:00
A tiff file without the TIFFTAG_PHOTOMETRIC tag will fail to load with ImproperImageHeader Exception.
line 1375 in coders\tiff.c initializes:
photometric=PHOTOMETRIC_RGB;
but the call in line 1378:
(TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric) != 1)
does not use that,
It has a case statement for the defaults which does not have a case for "TIFFTAG_PHOTOMETRIC"
Adding the following case at line 299 in tiff\libtiff\tif_aux.c fixes the issue.
case TIFFTAG_PHOTOMETRIC:
*va_arg(ap, uint16 *) = PHOTOMETRIC_RGB;
return (1);
line 1375 in coders\tiff.c initializes:
photometric=PHOTOMETRIC_RGB;
but the call in line 1378:
(TIFFGetFieldDefaulted(tiff,TIFFTAG_PHOTOMETRIC,&photometric) != 1)
does not use that,
It has a case statement for the defaults which does not have a case for "TIFFTAG_PHOTOMETRIC"
Adding the following case at line 299 in tiff\libtiff\tif_aux.c fixes the issue.
case TIFFTAG_PHOTOMETRIC:
*va_arg(ap, uint16 *) = PHOTOMETRIC_RGB;
return (1);