1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #19613 from Snuffleupagus/issue-19611

Let SMask/Mask images fallback to the parent image dimensions (issue 19611)
This commit is contained in:
Jonas Jenwald 2025-03-10 16:12:48 +01:00 committed by GitHub
commit b9e8844541
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 5 deletions

View file

@ -140,11 +140,26 @@ class PDFImage {
);
width = image.width;
height = image.height;
}
if (width < 1 || height < 1) {
throw new FormatError(
`Invalid image width: ${width} or height: ${height}`
);
} else {
const validWidth = typeof width === "number" && width > 0,
validHeight = typeof height === "number" && height > 0;
if (!validWidth || !validHeight) {
if (!image.fallbackDims) {
throw new FormatError(
`Invalid image width: ${width} or height: ${height}`
);
}
warn(
"PDFImage - using the Width/Height of the parent image, for SMask/Mask data."
);
if (!validWidth) {
width = image.fallbackDims.width;
}
if (!validHeight) {
height = image.fallbackDims.height;
}
}
}
this.width = width;
this.height = height;
@ -244,6 +259,10 @@ class PDFImage {
}
if (smask) {
// Provide fallback width/height values for corrupt SMask images
// (see issue19611.pdf).
smask.fallbackDims ??= { width, height };
this.smask = new PDFImage({
xref,
res,
@ -260,6 +279,10 @@ class PDFImage {
if (!imageMask) {
warn("Ignoring /Mask in image without /ImageMask.");
} else {
// Provide fallback width/height values for corrupt Mask images
// (see issue19611.pdf).
mask.fallbackDims ??= { width, height };
this.mask = new PDFImage({
xref,
res,

View file

@ -0,0 +1 @@
https://github.com/user-attachments/files/19102190/test.pdf

View file

@ -3913,6 +3913,14 @@
"rounds": 1,
"type": "eq"
},
{
"id": "issue19611",
"file": "pdfs/issue19611.pdf",
"md5": "169dc6df1c43dcb4659b2ddb6a4b39e4",
"rounds": 1,
"link": true,
"type": "eq"
},
{
"id": "issue1127-text",
"file": "pdfs/issue1127.pdf",