Skip to content

feat(plugins): add jxl plugin for JPEG XL export - #556

Merged
tinchox5 merged 1 commit into
zumerlab:mainfrom
jackskip22:jxl-plugin
Nov 10, 2026
Merged

tinchox5 merged 1 commit into
zumerlab:mainfrom
jackskip22:jxl-plugin

Conversation

@jackskip22

Copy link
Copy Markdown
Contributor

Adds a jxl plugin to @zumer/snapdom-plugins, as discussed in #541.

• jxl() adds toJxl(), toBlob({ format: 'jxl' }) and download({ format: 'jxl' }).
• Text and interface edges stay exact, photos follow the export's quality.
• Exports take the same options as toWebp(), plus effort (1-9, default 3), signal, onProgress and onEncoded. quality: 1 is exact.
• The encoder is rapier-jxl (MIT), loaded with import() the first time an export needs it.
• For browsers like Edge which can't display JPEG XL yet, toJxl() shows the result through an optional decoder or rejects with JXL_NOT_SHOWN. The saved Blob is always image/jxl.

Three requested fixes complete:

  1. Exact areas follow the capture's viewBox from context.meta.
  2. <html> is drawn from its top edge.
  3. pure: true for SnapDOM's memoization.

Tests

__tests__/plugin.jxl.test.js runs the encoder and checks that every pixel of the text sits inside an exact area on the canvas. Clipping, scrolled boxes, shadows, pseudo-elements, list markers, writing modes, form controls, excluded nodes, and <html> and <body> captures. Tests pass in Chromium, Firefox and WebKit.

Packaging

packages/plugins/package.json gets a ./jxl export and rapier-jxl 8.3.2 as an optional peer and dev dependency. The lockfile changes for that package and you are welcome to adjust any of it.

Also noticed during testing: capturing document.documentElement drops the top margin that collapses through <body> so the page is drawn 8px too high with the default body margin and about 21px when the page starts with <h1>. Skipping documentElement in neutralizeRootMarginCollapse should fix it and in the meantime, the plugin keeps such captures exact.

@tinchox5
tinchox5 merged commit c5a13bd into zumerlab:main Nov 10, 2026
@tinchox5

Copy link
Copy Markdown
Member

Thank you @jackskip22 ! Merging

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