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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ass-measure

v1.0.2

Published

Node.js native addon for measuring .ass subtitle dimensions

Readme

@montagao/ass-measure

A Node.js native addon for measuring dimensions of subtitle lines in ASS (Advanced SubStation Alpha) subtitle files.

Installation

npm install @montagao/ass-measure

Description

ass-measure is a native Node.js addon that provides functionality to analyze ASS subtitle files and determine the rendered dimensions of each subtitle line. This is useful for video processing applications, subtitle editors, or any situation where you need to know the actual display size of subtitles.

Features

  • Measures width and height of each subtitle line
  • Returns timing information (start and end times)
  • Handles all standard ASS subtitle features
  • Native implementation for performance

Usage

const measureAss = require('ass-measure');

// Parameters:
// 1. Path to the ASS subtitle file
// 2. Video width in pixels
// 3. Video height in pixels
const subtitleInfo = measureAss('./path/to/subtitles.ass', 1920, 1080);

// Result is an array of subtitle line objects
subtitleInfo.forEach(line => {
  console.log(`Line: "${line.text}"`);
  console.log(`Dimensions: ${line.width}x${line.height} pixels`);
  console.log(`Timing: ${line.startTime} - ${line.endTime}`);
});

CLI Usage Example

You can also use this package directly from the command line:

node -e "console.log(require('@montagao/ass-measure')('example.ass', 1920, 1080));"

Example output:

[ass] libass API version: 0x1703000
[ass] libass source: tarball: 0.17.3
[ass] Shaper: FriBidi 1.0.15 (SIMPLE) HarfBuzz-ng 10.0.1 (COMPLEX)
[ass] Using font provider coretext
[ass] Added subtitle file: 'example.ass' (2 styles, 3 events)
[ass] fontselect: (Arial, 400, 0) -> /System/Library/Fonts/Supplemental/Arial.ttf, -1, ArialMT
[
  {
    text: 'This is a test subtitle line 1',
    width: 518,
    height: 51,
    startTime: 1000,
    endTime: 5000
  },
  {
    text: 'This is a test subtitle line 2 with some more text',
    width: 922,
    height: 51,
    startTime: 6000,
    endTime: 10000
  },
  {
    text: 'This is a longer test subtitle line 3 with even more text to check dimensions',
    width: 1434,
    height: 52,
    startTime: 11000,
    endTime: 20000
  }
]

Return Value

The function returns an array of objects with the following properties for each subtitle line:

  • text - The text content of the subtitle line
  • width - The width of the rendered subtitle in pixels
  • height - The height of the rendered subtitle in pixels
  • startTime - The start time of the subtitle in milliseconds
  • endTime - The end time of the subtitle in milliseconds

Requirements

  • Node.js 14.x or higher
  • C++ compiler compatible with your platform

Building from Source

If you want to build from source, you'll need:

  1. Node.js and npm installed
  2. node-gyp installed globally (npm install -g node-gyp)
  3. C++ build tools for your platform:
    • Windows: Visual Studio Build Tools
    • macOS: Xcode Command Line Tools
    • Linux: GCC and related build tools

Then run:

git clone https://github.com/montagao/ass-measure.git
cd ass-measure
npm install

License

MIT

Author

Monta Gao