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

Optimize single-tile reads #348

Open thejohnhoffer opened 1 year ago

thejohnhoffer commented 1 year ago

This resolves issue #347. The _bulkReadable function detects when a single read should match an IFD buffer byte-for-byte. Instead of extracting every single pixel individually, this PR copies the IFD buffer to a single typed array whenever possible.

For our test case loading unsigned 16-bit 1024x1024 tiles, I observe this optimization is 4x faster thanv2.0.7.

I have written the code to optimize only when possible:

Testing

potion-cellar commented 1 year ago

+1