From e2ea9b693c015aac665fbbfd0397e7ede78d4afc Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 11 Jul 2017 16:25:47 +0200 Subject: [PATCH] In `src/core/jpg.js`, ensure that the Adobe JPEG marker always takes precedence, even when the color transform code is zero According to the PDF specification, please see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G6.2394361, if an Adobe JPEG marker is present it should always take precedence. This even seem to be consistent with the existing comment that is present in the code. Hence it seems reasonable to interpret `transformCode === 0` as no color conversion being necessary. Fixes the rendering of page 1 in `issue-4926` (from the test-suite), when the built-in `src/core/jpg.js` image decoder is used. --- src/core/jpg.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/core/jpg.js b/src/core/jpg.js index c6111d74e..1ccb9aec1 100644 --- a/src/core/jpg.js +++ b/src/core/jpg.js @@ -958,12 +958,13 @@ var JpegImage = (function JpegImageClosure() { return data; }, - _isColorConversionNeeded: function isColorConversionNeeded() { - if (this.adobe && this.adobe.transformCode) { - // The adobe transform marker overrides any previous setting - return true; - } else if (this.numComponents === 3) { - if (!this.adobe && this.colorTransform === 0) { + _isColorConversionNeeded() { + if (this.adobe) { + // The adobe transform marker overrides any previous setting. + return !!this.adobe.transformCode; + } + if (this.numComponents === 3) { + if (this.colorTransform === 0) { // If the Adobe transform marker is not present and the image // dictionary has a 'ColorTransform' entry, explicitly set to `0`, // then the colours should *not* be transformed. @@ -972,7 +973,7 @@ var JpegImage = (function JpegImageClosure() { return true; } // `this.numComponents !== 3` - if (!this.adobe && this.colorTransform === 1) { + if (this.colorTransform === 1) { // If the Adobe transform marker is not present and the image // dictionary has a 'ColorTransform' entry, explicitly set to `1`, // then the colours should be transformed.