Use readRasters for reading Tile Data #319
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As raised here: ome/bioformats#3643 (comment) it is possible that
bfconvert
will produce non-uniform tile sizes at lower resolutions. This PR makes us robust against that happening by usingreadRasters
universally (which includes using it instead of truncating tiles explicitly as in #308). The downside is that we have less control over what we're doing, which is why I resisted using this API for so long; however, I think I am comfortable now given the upshot and simplification of our code. Furthermore, we should not be hitting any of the expensive conditions inreadRasters
here: https://github.com/geotiffjs/geotiff.js/blob/8ef472f41b51d18074aece2300b6a8ad91a21ae1/src/geotiffimage.js#L363-L387so the performance should be identical modulo how endianness is handled (geotiff uses DataView API for that).
For an example image, http://localhost:8080/?image_url=https://viv-demo.storage.googleapis.com/AstroP65.ome.tiff breaks on master but does not now because one of its tile sizes is very odd (presumably because it was generated using
bfconvert
). For another example, you can download the image mentioned here: https://forum.image.sc/t/avivator-suggestion-for-improvement/46149/9?u=ilan-gold and drag-and-drop it over the canvas.