# wmf

> Windows MetaFile (WMF) parser

Latest version **1.0.2** (published 2020-03-16) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install wmf
pnpm add wmf
yarn add wmf
bun add wmf
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-03-16 |
| First published | 2015-10-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=0.8 |
| Dependencies | 0 |
| Unpacked size | 310.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | sheetjs |
| Maintainers | sheetjs |
| Keywords | wmf, image, office, word |

## Links

- npm: https://www.npmjs.com/package/wmf
- Repository: https://github.com/SheetJS/js-wmf
- Homepage: https://sheetjs.com/
- Issues: https://github.com/SheetJS/js-wmf/issues
- npm.io page: https://npm.io/package/wmf

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-03-16
- 1.0.1 — 2020-03-09
- 1.0.0 — 2020-03-01
- 0.5.0 — 2015-11-02
- 0.4.2 — 2015-11-01
- 0.4.1 — 2015-11-01
- 0.4.0 — 2015-10-31
- 0.3.0 — 2015-10-29
- 0.2.2 — 2015-10-27
- 0.2.1 — 2015-10-27
- 0.2.0 — 2015-10-26
- 0.1.2 — 2015-10-26
- 0.1.1 — 2015-10-26
- 0.1.0 — 2015-10-26

## README

# js-wmf

Processor for Windows MetaFile (WMF) files in JS (for the browser and nodejs).


## Installation

With [npm](https://www.npmjs.org/package/wmf):

```bash
$ npm install wmf
```

In the browser:

```html
<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 a `Canvas`.

### Notes

- The library assumes the global `ImageData` is available.  For nodejs-powered
  canvas implementations, a shim must be exposed as a global. Using the `canvas`
  npm package:

```js
const { createImageData } = require("canvas");
global.ImageData = createImageData;
```

- `OffscreenCanvas` in Chrome and some other Canvas implementations require
  the dimensions in the constructor:

```js
const size = WMF.image_size(data);
const canvas = new OffscreenCanvas(size[0], size[1]);
```


## Examples

<details>
  <summary><b>Browser Fetch into canvas</b> (click to show)</summary>

```js
// 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"));
})();
```

</details>

<details>
  <summary><b>NodeJS (using `canvas` npm module)</b> (click to show)</summary>

```js
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);
```

</details>


## 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

---
_Source: https://npm.io/package/wmf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
