Version 1.0.0
@stackline/wmf
Windows MetaFile (WMF) parser
Independent Stackline maintenance of wmf 1.0.2. The published license and original attribution are retained.
- npm 1.0.0
- License: Apache-2.0
- Node.js:
>=18
Installation
npm install --save-exact @stackline/wmf@1.0.0To keep the upstream import name:
npm install --save-exact wmf@npm:@stackline/wmf@1.0.0Usage and API
This is the README shipped with version 1.0.0. Retained upstream sections may describe older tooling, package names or browser compatibility. Use the exact scoped installation above, or the alias to preserve existing imports.
@stackline/wmf
Independently maintained Apache-2.0 fork of wmf@1.0.2. Original implementation, attribution and license are retained; this is not an official SheetJS release. The precise published source, git commit and SHA-512 integrity are recorded in UPSTREAM.json.
npm install @stackline/wmf
const library = require("@stackline/wmf");
Changes in 1.0.0
- Accept a 22-byte META_PLACEABLE prefix before META_HEADER in both dimension extraction and action parsing (upstream issues #1 and #2).
- Reject truncated headers and invalid record lengths before parsing, including zero-length records that cannot make progress. Header failures now use Error objects.
- Restore the exact TypeScript source associated with the npm gitHead (also embedded in its published source map), build both Node and browser exports with pinned esbuild, and include the previously missing TypeScript declarations.
Development and verification
Use Node.js 18 or newer for development (verified locally with Node 24). Run npm ci --ignore-scripts, npm run build, npm run lint, npm test, and npm run test:package. The fork declares Node >=18 for its rebuilt distribution; the original Node >=0.8 declaration is not carried forward. Browser builds expose the same WMF global and four public functions, without requiring a Node Buffer polyfill. The renderer itself is retained, not rewritten.
lint is a JavaScript syntax check, not a claim of a full style/security analysis. All packages have no runtime npm dependencies. npm audit reports registry advisories only; absence of findings is not proof that all format parsing is safe.
Five regression tests cover Buffer, Uint8Array, ArrayBuffer, browser-global exports, drawing entrypoint and malformed inputs. Rendering fidelity for arbitrary real-world WMF records is not claimed.
Sources reviewed on 2026-09-27:
- https://github.com/SheetJS/js-wmf/issues/1
- https://github.com/SheetJS/js-wmf/issues/2
- https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wmf/828e1864-7fe7-42d8-ab0a-1de161b32f27
Publication is performed by the repository GitHub workflow; do not publish from a local checkout. This fork does not modify or publish @stackline/xlsx.
Original upstream documentation
The following retained documentation describes the original library and may use its original package name. For this fork install and import the scoped package shown above.
js-wmf
Processor for Windows MetaFile (WMF) files in JS (for the browser and nodejs).
Installation
With npm:
$ npm install wmf
In the browser:
<script src="wmf.js"></script>
The browser exposes a variable WMF.
Usage
The data argument is expected to be an ArrayBuffer, Uint8Array or Buffer
WMF.image_size(data)extracts the image offset and extents, returns an Array[width, height]where both metrics are measured in pixels.WMF.draw_canvas(data, canvas)parses the WMF and draws to aCanvas.
Notes
- The library assumes the global
ImageDatais available. For nodejs-powered canvas implementations, a shim must be exposed as a global. Using thecanvasnpm package:
const { createImageData } = require("canvas");
global.ImageData = createImageData;
OffscreenCanvasin Chrome and some other Canvas implementations require the dimensions in the constructor:
const size = WMF.image_size(data);
const canvas = new OffscreenCanvas(size[0], size[1]);
Examples
Browser Fetch into canvas (click to show)
// assume `canvas` is a DOM element
(async() => {
const res = await fetch("url/for/image.wmf");
const ab = await res.arrayBuffer();
WMF.draw_canvas(ab, document.getElementById("canvas"));
})();
NodeJS (using `canvas` npm module) (click to show)
const { createCanvas, createImageData } = require("canvas");
global.ImageData = createImageData;
const size = WMF.image_size(data);
const canvas = createCanvas(size[0], size[1]);
WMF.draw_canvas(data, canvas);
License
Please consult the attached LICENSE file for details. All rights not explicitly granted by the Apache 2.0 License are reserved by the Original Author.
References
MS-WMF: Windows Metafile Format
Published files and origin
- LICENSE
- NOTICE
- UPSTREAM.json
- README.md
- Package and archive metadata
- Full text documentation
- Exact npm archive
These documents were read from the existing npm 1.0.0 archive. Its SHA-512 matches the current registry integrity value. This documentation update does not publish a new package or establish a new provenance or immutable-release verification.
Archive integrity
sha512-n/UuyEfZf0bpLNUI7kw8Nx2/z97DjtRuIdzQUOMAb3uIvhTAnd4E5TDmpFdzHSYipCPYlHwehORbBhrd53RuzQ==