You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems geotiff.js 2.1.3 is not able to decode a tiled GeoTIFF file I wanted to parse using node.js (v 22.3.0).
It seems the reason is that the TileByteCounts and TileOffsets arrays in the File Directory object somehow end up having only zero values. And then the decoding of the image tiles fails.
The error occurs when calling the image.readRasters() method - but I suspect the root cause lies in the parsing of the File Directory information.
See attachment for a minimal code example - and data file - that can be used to reproduce the issue. testcase.zip
The text was updated successfully, but these errors were encountered:
Small update: It seems the two arrays start with zero values but do not have only zero values. I tried using exiftool to verify/read out the File Directory info from the test tiff, and geotiff.js and exiftool produce the same result. So I assume that this is correct. This means the File Directory parsing in tiff.getImage() is correct - and that the error happens in image.readRasters() when using the array values to decode the tiles.
Have found out more about what happens when the code crashes:
In geotiffimage.js, line 485:
const buffer = tile.data;
const dataView = new DataView(buffer);
...the code creates a dataview that stores 0 bytes (the tile.data array has zero length).
In geotiffimage.js, line 500:
const value = reader.call(dataView, pixelOffset + srcSampleOffsets[si], littleEndian);
...the code tries to read out values from a zero-sized dataview, and this makes it fail.
Could it be that the code should just skip tiles where the TileByteCounts value is zero? Or is the data in the example tiff file inherently wrong? (Both GDAL and QGIS can successfully open the file.)
It seems geotiff.js 2.1.3 is not able to decode a tiled GeoTIFF file I wanted to parse using node.js (v 22.3.0).
It seems the reason is that the
TileByteCounts
andTileOffsets
arrays in the File Directory object somehow end up having only zero values. And then the decoding of the image tiles fails.The error occurs when calling the
image.readRasters()
method - but I suspect the root cause lies in the parsing of the File Directory information.See attachment for a minimal code example - and data file - that can be used to reproduce the issue.
testcase.zip
The text was updated successfully, but these errors were encountered: