diff --git a/lib/image/jpeg.js b/lib/image/jpeg.js index 6787191f..7eaceddb 100644 --- a/lib/image/jpeg.js +++ b/lib/image/jpeg.js @@ -132,7 +132,7 @@ class JPEG { this.width = this.data.readUInt16BE(pos); pos += 2; - const channels = this.data[pos + 1]; + const channels = this.data[pos]; this.colorSpace = COLOR_SPACE_MAP[channels]; this.obj = null; diff --git a/tests/unit/image.spec.js b/tests/unit/image.spec.js index 24a1ca5e..d76ad077 100644 --- a/tests/unit/image.spec.js +++ b/tests/unit/image.spec.js @@ -29,6 +29,12 @@ describe('Image', function () { expect(jpeg.orientation).toBe(1); }); + test('RGB JPEG is parsed with DeviceRGB color space (regression)', () => { + const data = fs.readFileSync('./tests/images/bee.jpg'); + const jpeg = new JPEG(data, 'test'); + expect(jpeg.colorSpace).toBe('DeviceRGB'); + }); + describe('opacity', function () { test('adds an ExtGState with the correct ca value', () => { document.image('./tests/images/bee.png', 0, 0, { opacity: 0.5 });