Skip to content

Commit

Permalink
Merge pull request #9954 from Snuffleupagus/rm-PDFImage-Filter-warn
Browse files Browse the repository at this point in the history
Stop warning for non-Name /Filter entries in the `PDFImage` constructor (PR 9897 follow-up)
  • Loading branch information
timvandermeij authored Aug 3, 2018
2 parents 8a4be24 + a504bef commit ee9a5c1
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions src/core/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,24 @@ var PDFImage = (function PDFImageClosure() {
mask = null, isMask = false, pdfFunctionFactory, }) {
this.image = image;
var dict = image.dict;
if (dict.has('Filter')) {
const filter = dict.get('Filter');
if (isName(filter)) {
switch (filter.name) {
case 'JPXDecode':
var jpxImage = new JpxImage();
jpxImage.parseImageProperties(image.stream);
image.stream.reset();

image.width = jpxImage.width;
image.height = jpxImage.height;
image.bitsPerComponent = jpxImage.bitsPerComponent;
image.numComps = jpxImage.componentsCount;
break;
case 'JBIG2Decode':
image.bitsPerComponent = 1;
image.numComps = 1;
break;
}
} else {
warn(`PDFImage - invalid /Filter entry in dictionary: "${filter}".`);

const filter = dict.get('Filter');
if (isName(filter)) {
switch (filter.name) {
case 'JPXDecode':
var jpxImage = new JpxImage();
jpxImage.parseImageProperties(image.stream);
image.stream.reset();

image.width = jpxImage.width;
image.height = jpxImage.height;
image.bitsPerComponent = jpxImage.bitsPerComponent;
image.numComps = jpxImage.componentsCount;
break;
case 'JBIG2Decode':
image.bitsPerComponent = 1;
image.numComps = 1;
break;
}
}
// TODO cache rendered images?
Expand Down

0 comments on commit ee9a5c1

Please sign in to comment.