Skip to content

fix(masks): use luminosity mask by default - CU-86c97q74b#2

Merged
AshishBhattarai merged 3 commits intomasterfrom
support-luminosity-mask
Apr 8, 2026
Merged

fix(masks): use luminosity mask by default - CU-86c97q74b#2
AshishBhattarai merged 3 commits intomasterfrom
support-luminosity-mask

Conversation

@AshishBhattarai
Copy link
Copy Markdown
Collaborator

@AshishBhattarai AshishBhattarai commented Apr 7, 2026

  • should default to luminosity mask for masks

@AshishBhattarai AshishBhattarai changed the title fix(masks): use luminosity mask by default - CU-NONE fix(masks): use luminosity mask by default - CU-86c97q74b Apr 7, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates SVG mask handling so that <mask> defaults to a luminosity-based SMask (instead of alpha), while still supporting explicit alpha masks, and extends ICC profile metadata to better handle CMYK-backed masking.

Changes:

  • Add a luminosity SMask implementation and make it the default for SVG <mask> (with opt-in alpha via mask-type="alpha").
  • Split mask application into explicit alpha vs luminosity helpers and adjust clipPath to continue using alpha masking semantics.
  • Extend ICC profile handling with a type field (and plumb it through iccProfile) to support CMYK-specific mask backdrop configuration.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
package.json Updates package version (currently appears to regress).
lib/write_svg.js Implements luminosity masks as default and supports mask-type switching between alpha and luminosity.
lib/mixins/color_space.js Extends iccProfile API with an optional type parameter.
lib/icc_profile.js Stores ICC profile type (defaults based on channel count).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

package.json Outdated
"vector"
],
"version": "0.17.56",
"version": "0.17.6",
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package version change looks like a regression/typo: it goes from 0.17.56 to 0.17.6 (lower version and missing a digit). This can break publishing/upgrade paths; please use the correct next semver (likely 0.17.57 or keep the existing patch format).

Suggested change
"version": "0.17.6",
"version": "0.17.57",

Copilot uses AI. Check for mistakes.
Comment on lines +3346 to +3355
const maskType = this.attr('mask-type') ?? 'luminance';
this.clip();
this.drawChildren(false, true);
doc.restore();
docEndGroup(group);
docApplyMask(group);
if (maskType === 'alpha') {
docApplyAlphaMask(group);
} else {
docApplyMask(group);
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mask-type is read via getAttribute and then compared case-sensitively to 'alpha'. Since mask-type is a CSS keyword/presentation attribute, values should be treated case-insensitively; consider normalizing (e.g., String(...).toLowerCase()) or using the style getter so valid inputs like Alpha/ALPHA work.

Copilot uses AI. Check for mistakes.
Comment on lines +692 to 697
function docApplyAlphaMask(group) {
const name = 'M' + (doc._maskCount = (doc._maskCount || 0) + 1);
const gstate = doc.ref({
Type: 'ExtGState',
CA: 1,
ca: 1,
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside docApplyAlphaMask, the inline comment We only support alpha mask for now has become misleading now that luminosity masks are also supported via docApplyMask. Please reword it to clarify this helper applies an alpha SMask specifically (rather than implying alpha is the only supported mask mode overall).

Copilot uses AI. Check for mistakes.
Comment on lines +8 to 11
iccProfile(label, data, channels, alternate, type) {
const profile = new ICCProfile(label, data, channels, alternate, type);
profile.embed(this);
this._colorProfiles[label] = profile;
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The public iccProfile(...) API now accepts a new type parameter, but the TypeScript declarations still expose only 4 parameters (see types/pdfkit.d.ts). Please update the .d.ts signature to keep the public API consistent for typed consumers.

Copilot uses AI. Check for mistakes.
@AshishBhattarai AshishBhattarai merged commit 1525b89 into master Apr 8, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants