Skip to content

Commit e2aed8b

Browse files
committedMay 12, 2023
be more forgiving when fileDirectory.SampleFormat does not have all values populated, such as in bioformats ome tif files
1 parent f15d770 commit e2aed8b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/geotiffimage.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ class GeoTIFFImage {
295295
}
296296

297297
getReaderForSample(sampleIndex) {
298-
const format = this.fileDirectory.SampleFormat
299-
? this.fileDirectory.SampleFormat[sampleIndex] : 1;
298+
const format = this.getSampleFormat(sampleIndex);
300299
const bitsPerSample = this.fileDirectory.BitsPerSample[sampleIndex];
301300
switch (format) {
302301
case 1: // unsigned integer data
@@ -339,7 +338,8 @@ class GeoTIFFImage {
339338

340339
getSampleFormat(sampleIndex = 0) {
341340
return this.fileDirectory.SampleFormat
342-
? this.fileDirectory.SampleFormat[sampleIndex] : 1;
341+
? (this.fileDirectory.SampleFormat[sampleIndex] ?? Math.max.apply(null, this.fileDirectory.SampleFormat))
342+
: 1;
343343
}
344344

345345
getBitsPerSample(sampleIndex = 0) {

0 commit comments

Comments
 (0)