gdal icon indicating copy to clipboard operation
gdal copied to clipboard

GEOTIFF ERROR: TIFFReadDirectory:Incorrect count for "SampleFormat"

Open michkowalczuk opened this issue 1 month ago • 4 comments

What is the bug?

gdalinfo 325355935_col.tiff (attached) returns error:

ERROR 1: 325355935_col.tiff: TIFFReadDirectory:Incorrect count for "SampleFormat"
gdalinfo failed - unable to open '325355935_col.tiff'

325355935_col.zip

Steps to reproduce the issue

See above

Versions and provenance

Windows 11 GDAL 3.12.0 "Chicoutimi", released 2025/11/03 using conda libgdal

Additional context

No response

michkowalczuk avatar Nov 24 '25 18:11 michkowalczuk

gdalinfo 325355935_col.tiff (attached) returns error:

totally justified. This file is not a conformant TIFF file:

$ tiffdump 325355935_col.tiff
[...]
SamplesPerPixel (277) SHORT (3) 1<4>
[...]
SampleFormat (339) SHORT (3) 3<1 1 1>

So it advertizes 4 channels in SamplesPerPixel, but the SampleFormat tag only contains 3 values, wheras it should contain 4. This should be reported to the data producer

rouault avatar Nov 24 '25 18:11 rouault

But Windows default Image app can open it. So maybe a specialized geospatial library also should...? ;-)

michkowalczuk avatar Nov 24 '25 18:11 michkowalczuk

The Windows viewers were the only ones which could open the image in my short test. IrfanView, GIMP, and some others did not. Save a copy with the Windows viewer and GDAL will be happy with it. I wouldn't say that the image is fixed because by the specification https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf SampleFormat and SamplesPerPixel are synchronized for a purpose.

jratike80 avatar Nov 24 '25 19:11 jratike80

libtiff enhancement to support that non-conformity in https://gitlab.com/libtiff/libtiff/-/merge_requests/770

rouault avatar Nov 25 '25 15:11 rouault

This has been fixed both in upstream libtiff, and in the GDAL libtiff internal copy in d6a72c36be223065adf39fa58284598c3dbd3f00

rouault avatar Dec 15 '25 23:12 rouault