geotiffjs / geotiff.js

geotiff.js is a small library to parse TIFF files for visualization or analysis. It is written in pure JavaScript, and is usable in both the browser and node.js applications.
https://geotiffjs.github.io/
MIT License
859 stars 179 forks source link

Performance issue when loading individual tiles #347

Open thejohnhoffer opened 1 year ago

thejohnhoffer commented 1 year ago

What I observe

For each loaded tile, this line in _readRaster copies every image pixel from the tile buffer one-by-one. Each of our tiles (1024px by 1024px) therefore call this function over a million times when loaded. For our case of direct rendering of hundreds of tiles, This produces a 4x slowdown compared to a direct copy from tile buffer to typed array.

What I expect

Only one buffer to array conversion should be needed to read one tile that byte-for-byte matches an IFD.

Proposed solution

PR #348