From 867af5c1e50803dda61281454987d3937c08db99 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Thu, 26 Mar 2026 14:35:31 +0100 Subject: [PATCH] Display mask in the tree view in the debugger --- src/core/document.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/document.js b/src/core/document.js index 74cfdaefd..5777c998e 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -2082,10 +2082,13 @@ class PDFDocument { const obj = Object.create(null); obj.dict = await this.toJSObject(dict, false); - if ( - isName(dict.get("Type"), "XObject") && - isName(dict.get("Subtype"), "Image") - ) { + if (isName(dict.get("Subtype"), "Image")) { + const isImageMask = dict.get("ImageMask") === true; + if (isImageMask) { + dict.set("ImageMask", false); + dict.set("IM", false); + value.numComps = value.bitsPerComponent = 1; + } try { const pdfFunctionFactory = new PDFFunctionFactory({ xref: this.xref, @@ -2113,6 +2116,11 @@ class PDFDocument { } catch { // Fall through to regular byte stream if image decoding fails. } + if (isImageMask) { + dict.set("ImageMask", true); + delete value.numComps; + delete value.bitsPerComponent; + } } if (isName(dict.get("Subtype"), "Form")) {