Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop warning for non-Name /Filter entries in the PDFImage constructor (PR 9897 follow-up) #9954

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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