Skip to content

Commit

Permalink
be more forgiving when fileDirectory.SampleFormat does not have all v…
Browse files Browse the repository at this point in the history
…alues populated, such as in bioformats ome tif files
  • Loading branch information
jeffpeck10x committed May 12, 2023
1 parent f15d770 commit e2aed8b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/geotiffimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e2aed8b

Please sign in to comment.