Comparing version 4.1.2 to 4.1.3
@@ -0,1 +1,10 @@ | ||
## [4.1.3](https://github.com/image-js/tiff/compare/v4.1.2...v4.1.3) (2020-08-07) | ||
### Bug Fixes | ||
* support images that do not define `samplesPerPixel` ([2c2587b](https://github.com/image-js/tiff/commit/2c2587b4307ef22225d38f5d24968c678bf6fa54)) | ||
## [4.1.2](https://github.com/image-js/tiff/compare/v4.1.1...v4.1.2) (2020-08-06) | ||
@@ -2,0 +11,0 @@ |
@@ -153,3 +153,3 @@ import { IOBuffer } from 'iobuffer'; | ||
// WhiteIsZero: we invert the values | ||
const bitDepth = validateBitDepth(ifd.bitsPerSample); | ||
const bitDepth = ifd.bitsPerSample; | ||
const maxValue = Math.pow(2, bitDepth) - 1; | ||
@@ -164,3 +164,3 @@ for (let i = 0; i < ifd.data.length; i++) { | ||
const height = ifd.height; | ||
const bitDepth = validateBitDepth(ifd.bitsPerSample); | ||
const bitDepth = ifd.bitsPerSample; | ||
const sampleFormat = ifd.sampleFormat; | ||
@@ -217,3 +217,3 @@ const size = width * height * ifd.samplesPerPixel; | ||
applyPredictor(ifd) { | ||
const bitDepth = validateBitDepth(ifd.bitsPerSample); | ||
const bitDepth = ifd.bitsPerSample; | ||
switch (ifd.predictor) { | ||
@@ -281,14 +281,2 @@ case 1: { | ||
} | ||
function validateBitDepth(bitDepth) { | ||
if (typeof bitDepth !== 'number') { | ||
const bitDepthArray = bitDepth; | ||
bitDepth = bitDepthArray[0]; | ||
for (let i = 0; i < bitDepthArray.length; i++) { | ||
if (bitDepthArray[i] !== bitDepth) { | ||
throw unsupported('bit depth', bitDepthArray); | ||
} | ||
} | ||
} | ||
return bitDepth; | ||
} | ||
//# sourceMappingURL=tiffDecoder.js.map |
@@ -42,3 +42,7 @@ import Ifd from './ifd'; | ||
get bitsPerSample() { | ||
return this.get(258); | ||
const data = this.get(258); | ||
if (data && typeof data !== 'number') { | ||
return data[0]; | ||
} | ||
return data; | ||
} | ||
@@ -67,3 +71,3 @@ get compression() { | ||
get samplesPerPixel() { | ||
return this.get(277); | ||
return this.get(277) || 1; | ||
} | ||
@@ -70,0 +74,0 @@ get rowsPerStrip() { |
@@ -158,3 +158,3 @@ "use strict"; | ||
// WhiteIsZero: we invert the values | ||
const bitDepth = validateBitDepth(ifd.bitsPerSample); | ||
const bitDepth = ifd.bitsPerSample; | ||
const maxValue = Math.pow(2, bitDepth) - 1; | ||
@@ -169,3 +169,3 @@ for (let i = 0; i < ifd.data.length; i++) { | ||
const height = ifd.height; | ||
const bitDepth = validateBitDepth(ifd.bitsPerSample); | ||
const bitDepth = ifd.bitsPerSample; | ||
const sampleFormat = ifd.sampleFormat; | ||
@@ -222,3 +222,3 @@ const size = width * height * ifd.samplesPerPixel; | ||
applyPredictor(ifd) { | ||
const bitDepth = validateBitDepth(ifd.bitsPerSample); | ||
const bitDepth = ifd.bitsPerSample; | ||
switch (ifd.predictor) { | ||
@@ -287,14 +287,2 @@ case 1: { | ||
} | ||
function validateBitDepth(bitDepth) { | ||
if (typeof bitDepth !== 'number') { | ||
const bitDepthArray = bitDepth; | ||
bitDepth = bitDepthArray[0]; | ||
for (let i = 0; i < bitDepthArray.length; i++) { | ||
if (bitDepthArray[i] !== bitDepth) { | ||
throw unsupported('bit depth', bitDepthArray); | ||
} | ||
} | ||
} | ||
return bitDepth; | ||
} | ||
//# sourceMappingURL=tiffDecoder.js.map |
@@ -47,3 +47,7 @@ "use strict"; | ||
get bitsPerSample() { | ||
return this.get(258); | ||
const data = this.get(258); | ||
if (data && typeof data !== 'number') { | ||
return data[0]; | ||
} | ||
return data; | ||
} | ||
@@ -72,3 +76,3 @@ get compression() { | ||
get samplesPerPixel() { | ||
return this.get(277); | ||
return this.get(277) || 1; | ||
} | ||
@@ -75,0 +79,0 @@ get rowsPerStrip() { |
{ | ||
"name": "tiff", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"description": "TIFF image decoder written entirely in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -183,3 +183,3 @@ import { IOBuffer } from 'iobuffer'; | ||
// WhiteIsZero: we invert the values | ||
const bitDepth = validateBitDepth(ifd.bitsPerSample); | ||
const bitDepth = ifd.bitsPerSample; | ||
const maxValue = Math.pow(2, bitDepth) - 1; | ||
@@ -196,3 +196,3 @@ for (let i = 0; i < ifd.data.length; i++) { | ||
const bitDepth = validateBitDepth(ifd.bitsPerSample); | ||
const bitDepth = ifd.bitsPerSample; | ||
const sampleFormat = ifd.sampleFormat; | ||
@@ -273,3 +273,3 @@ const size = width * height * ifd.samplesPerPixel; | ||
private applyPredictor(ifd: TiffIfd): void { | ||
const bitDepth = validateBitDepth(ifd.bitsPerSample); | ||
const bitDepth = ifd.bitsPerSample; | ||
switch (ifd.predictor) { | ||
@@ -364,14 +364,1 @@ case 1: { | ||
} | ||
function validateBitDepth(bitDepth: number[] | number): number { | ||
if (typeof bitDepth !== 'number') { | ||
const bitDepthArray = bitDepth; | ||
bitDepth = bitDepthArray[0]; | ||
for (let i = 0; i < bitDepthArray.length; i++) { | ||
if (bitDepthArray[i] !== bitDepth) { | ||
throw unsupported('bit depth', bitDepthArray); | ||
} | ||
} | ||
} | ||
return bitDepth; | ||
} |
@@ -50,3 +50,7 @@ import Ifd from './ifd'; | ||
public get bitsPerSample(): number { | ||
return this.get(258); | ||
const data = this.get(258); | ||
if (data && typeof data !== 'number') { | ||
return data[0]; | ||
} | ||
return data; | ||
} | ||
@@ -75,3 +79,3 @@ public get compression(): number { | ||
public get samplesPerPixel(): number { | ||
return this.get(277); | ||
return this.get(277) || 1; | ||
} | ||
@@ -78,0 +82,0 @@ public get rowsPerStrip(): number { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
175575
3324