npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

wmf-creator

v1.0.1

Published

A TypeScript library for generating Windows Metafile (WMF) images

Readme

WMF Creator

A TypeScript library for generating Windows Metafile (WMF) images programmatically. Create vector graphics with pens, brushes, and various shapes.

Installation

npm install wmf-creator

Usage

Basic Example

import { generateWMF, PenStyle } from 'wmf-creator';

const blob = generateWMF({
  width: 100,
  height: 75,
  pixelsPerInch: 5,
  objects: [
    {
      type: 'pen',
      penStyle: PenStyle.SOLID,
      color: 0x000000, // black
      width: 1
    },
    {
      type: 'brush',
      color: 0x00FF00 // green
    },
  ],
  entities: [
    {
      type: 'rectangle',
      x: 10,
      y: 10,
      width: 50,
      height: 30,
      pen: 0, // index of the pen object
      brush: 1 // index of the brush object
    }
  ]
});

// In browser - download the file
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'image.wmf';
a.click();

Advanced Usage with Builder

import { Builder, PenStyle, RecordType } from 'wmf-creator';

const builder = new Builder(200, 150, 600);

// Create objects
const penIndex = builder.writePen(PenStyle.SOLID, 0xFF0000, 2); // red pen
const brushIndex = builder.writeBrush(0x0000FF); // blue brush

// Select and draw
builder.selectPen(penIndex);
builder.selectBrush(brushIndex);
builder.writeCircle(50, 50, 30);

builder.endFile();
const arrayBuffer = builder.toArrayBuffer();
const blob = new Blob([arrayBuffer], { type: 'application/x-wmf' });

API Reference

Main Functions

generateWMF(data: ImageObject): Blob

Generates a WMF file from a structured image object.

Classes

Builder

Low-level builder for creating WMF files step by step.

Constructor: new Builder(width?: number, height?: number, pixelsPerInch?: number)

Methods:

  • writePen(penStyle: PenStyle, color: number, width: number): number
  • writeBrush(color: number | null): number
  • writeFont(name: string, fontFamily: FamilyFont, height: number, weight: number, italic: boolean, underline: boolean, strikeout: boolean): number
  • selectPen(penIndex: number): void
  • selectBrush(brushIndex: number): void
  • selectFont(fontIndex: number): void
  • writeLine(x1: number, y1: number, x2: number, y2: number): void
  • writeRectangle(x: number, y: number, width: number, height: number): void
  • writeEllipse(x: number, y: number, width: number, height: number): void
  • writeCircle(x: number, y: number, radius: number): void
  • endFile(): void
  • toArrayBuffer(): ArrayBuffer

Enums

PenStyle

  • SOLID, DASH, DOT, DASHDOT, DASHDOTDOT, NULL, INSIDEFRAME

FamilyFont

  • DONTCARE, ROMAN, SWISS, MODERN, SCRIPT, DECORATIVE

Types

ImageObject

type ImageObject = {
  width: number;
  height: number;
  pixelsPerInch: number;
  objects: Object[];
  entities: Entity[];
}

See the example file for detailed usage patterns.

License

ISC