Processor for Windows MetaFile (WMF) files in JS (for the browser and nodejs).
$ npm install wmf
In the browser:
The browser exposes a variable
data argument is expected to be an
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 a
- The library assumes the global
ImageDatais available. For nodejs-powered canvas implementations, a shim must be exposed as a global. Using the
const createImageData = ;globalImageData = createImageData;
OffscreenCanvasin Chrome and some other Canvas implementations require the dimensions in the constructor:
const size = WMF;const canvas = size0 size1;
Browser Fetch into canvas (click to show)
// assume `canvas` is a DOM elementasyncconst res = await ;const ab = await res;WMF;;
NodeJS (using `canvas` npm module) (click to show)
const createCanvas createImageData = ;globalImageData = createImageData;const size = WMF;const canvas = ;WMF;
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.
MS-WMF: Windows Metafile Format