Tiff image without TIFFTAG_PHOTOMETRIC won't load

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
wmandrews
Posts: 1
Joined: 2019-08-21T19:08:17-07:00
Authentication code: 1152

Tiff image without TIFFTAG_PHOTOMETRIC won't load

Post by wmandrews »

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);
246246
Posts: 190
Joined: 2015-07-06T07:38:22-07:00
Authentication code: 1151

Re: Tiff image without TIFFTAG_PHOTOMETRIC won't load

Post by 246246 »

TIFFTAG_PHOTOMETRIC is required field. There is no default. See https://www.awaresystems.be/imaging/tif ... ation.html
Post Reply