mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #15221 from Snuffleupagus/issue-15220
Support images with /Filter-entries that contain Arrays (issue 15220)
This commit is contained in:
commit
8ebd2d3dfd
3 changed files with 31 additions and 16 deletions
|
@ -103,25 +103,31 @@ class PDFImage {
|
|||
const dict = image.dict;
|
||||
|
||||
const filter = dict.get("F", "Filter");
|
||||
let filterName;
|
||||
if (filter instanceof Name) {
|
||||
switch (filter.name) {
|
||||
case "JPXDecode":
|
||||
const 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;
|
||||
filterName = filter.name;
|
||||
} else if (Array.isArray(filter)) {
|
||||
const filterZero = xref.fetchIfRef(filter[0]);
|
||||
if (filterZero instanceof Name) {
|
||||
filterName = filterZero.name;
|
||||
}
|
||||
}
|
||||
// TODO cache rendered images?
|
||||
switch (filterName) {
|
||||
case "JPXDecode":
|
||||
const 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;
|
||||
}
|
||||
|
||||
let width = dict.get("W", "Width");
|
||||
let height = dict.get("H", "Height");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue