-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Support images with /Filter-entries that contain Arrays (issue 15220) #15221
Conversation
This patch "borrows" the code found in the `Parser.makeInlineImage`-method, to ensure that JBIG2 and JPX images can be rendered correctly.
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/fd1048a8600b836/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/90f76d06e246413/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/fd1048a8600b836/output.txt Total script time: 25.67 mins
Image differences available at: http://54.241.84.105:8877/fd1048a8600b836/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/90f76d06e246413/output.txt Total script time: 28.64 mins
Image differences available at: http://54.193.163.58:8877/90f76d06e246413/reftest-analyzer.html#web=eq.log |
break; | ||
filterName = filter.name; | ||
} else if (Array.isArray(filter)) { | ||
const filterZero = xref.fetchIfRef(filter[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, we're only considering the first entry in the array (and the same here
Line 510 in 14a8b81
const filterZero = this.xref.fetchIfRef(filter[0]); |
If I correctly read the specs, "Filter" can be a name or an array, and on page 216 there is this example:

Does it mean that other filters are just skipped ? or are they considered somewhere else in the code ? or did I wrongly read the docs ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it mean that other filters are just skipped ? or are they considered somewhere else in the code ?
Nope, all available filters are considered (in order) when decoding the stream; please see
Lines 692 to 723 in 14a8b81
filter(stream, dict, length) { | |
let filter = dict.get("F", "Filter"); | |
let params = dict.get("DP", "DecodeParms"); | |
if (filter instanceof Name) { | |
if (Array.isArray(params)) { | |
warn("/DecodeParms should not be an Array, when /Filter is a Name."); | |
} | |
return this.makeFilter(stream, filter.name, length, params); | |
} | |
let maybeLength = length; | |
if (Array.isArray(filter)) { | |
const filterArray = filter; | |
const paramsArray = params; | |
for (let i = 0, ii = filterArray.length; i < ii; ++i) { | |
filter = this.xref.fetchIfRef(filterArray[i]); | |
if (!(filter instanceof Name)) { | |
throw new FormatError(`Bad filter name "${filter}"`); | |
} | |
params = null; | |
if (Array.isArray(paramsArray) && i in paramsArray) { | |
params = this.xref.fetchIfRef(paramsArray[i]); | |
} | |
stream = this.makeFilter(stream, filter.name, maybeLength, params); | |
// After the first stream the `length` variable is invalid. | |
maybeLength = null; | |
} | |
} | |
return stream; | |
} |
For images, which is what we're dealing with here, it should suffice to consider the first /Filter-entry to determine its kind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
/botio makeref |
From: Bot.io (Linux m4)ReceivedCommand cmd_makeref from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/b9958279503aeb9/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/4f9c38e5daec6fb/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/b9958279503aeb9/output.txt Total script time: 22.14 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/4f9c38e5daec6fb/output.txt Total script time: 22.68 mins
|
This patch "borrows" the code found in the
Parser.makeInlineImage
-method, to ensure that JBIG2 and JPX images can be rendered correctly.