From e2aed8b06b01409a1ce8a0f1fc96a1ecdfb691d3 Mon Sep 17 00:00:00 2001 From: Jeff Peck Date: Fri, 12 May 2023 18:37:18 -0400 Subject: [PATCH] be more forgiving when fileDirectory.SampleFormat does not have all values populated, such as in bioformats ome tif files --- src/geotiffimage.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/geotiffimage.js b/src/geotiffimage.js index 21994643..ce1f4030 100644 --- a/src/geotiffimage.js +++ b/src/geotiffimage.js @@ -295,8 +295,7 @@ class GeoTIFFImage { } getReaderForSample(sampleIndex) { - const format = this.fileDirectory.SampleFormat - ? this.fileDirectory.SampleFormat[sampleIndex] : 1; + const format = this.getSampleFormat(sampleIndex); const bitsPerSample = this.fileDirectory.BitsPerSample[sampleIndex]; switch (format) { case 1: // unsigned integer data @@ -339,7 +338,8 @@ class GeoTIFFImage { getSampleFormat(sampleIndex = 0) { return this.fileDirectory.SampleFormat - ? this.fileDirectory.SampleFormat[sampleIndex] : 1; + ? (this.fileDirectory.SampleFormat[sampleIndex] ?? Math.max.apply(null, this.fileDirectory.SampleFormat)) + : 1; } getBitsPerSample(sampleIndex = 0) {