Skip to content

Commit

Permalink
Merge pull request #10063 from Snuffleupagus/JPEG-isSourcePDF-assert
Browse files Browse the repository at this point in the history
Slightly improve the `isSourcePDF` parameter handling in `JpegImage` (PR 10031 follow-up)
  • Loading branch information
timvandermeij authored Sep 12, 2018
2 parents 9c764da + 5181172 commit 29683d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/jpg.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
/* eslint-disable no-multi-spaces */

import { warn } from '../shared/util';
import { assert, warn } from '../shared/util';

let JpegError = (function JpegErrorClosure() {
function JpegError(msg) {
Expand Down Expand Up @@ -1026,7 +1026,7 @@ var JpegImage = (function JpegImageClosure() {
// out-of-box behaviour when `JpegImage` is used standalone, default to
// inverting JPEG (CMYK) images if and only if the image data does *not*
// come from a PDF file and no `decodeTransform` was passed by the user.
if (!transform && numComponents === 4 && !isSourcePDF) {
if (!isSourcePDF && numComponents === 4 && !transform) {
transform = new Int32Array([
-256, 255, -256, 255, -256, 255, -256, 255]);
}
Expand Down Expand Up @@ -1180,6 +1180,10 @@ var JpegImage = (function JpegImageClosure() {
},

getData({ width, height, forceRGB = false, isSourcePDF = false, }) {
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('TESTING && !LIB')) {
assert(isSourcePDF === true,
'JpegImage.getData: Unexpected "isSourcePDF" value for PDF files.');
}
if (this.numComponents > 4) {
throw new JpegError('Unsupported color mode');
}
Expand Down

0 comments on commit 29683d4

Please sign in to comment.