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

@paragraf/color

v0.7.0

Published

ICC color management for the paragraf typography library

Readme

@paragraf/color

ICC v2/v4 color management for the paragraf typography library.

Pure TypeScript. No native deps. No bundled ICC profile files.

What it does

  • Parse ICC v2/v4 profiles: matrix primaries, gamma/LUT tone curves, mft2 CLUT tags
  • Transform discrete color values (text fills, rules) between profiles via:
    • Matrix + TRC path (e.g. sRGB device → CIEXYZ D50)
    • Chained matrix + XYZ→Lab + LUT path (e.g. sRGB → FOGRA39 CMYK)
    • 3D tetrahedral CLUT interpolation (per ICC spec §10.8)
  • Synthesize a built-in sRGB IEC61966-2.1 profile in memory — no disk access, valid ICC v4 bytes ready for PDF OutputIntent embedding
  • Export TaggedColor — the integration seam for paragraf-knuth-plass v0.11 PDF/X output

Install

npm install @paragraf/color

Quick start

import { createColorManager } from '@paragraf/color';

const mgr = createColorManager();
const srgb = mgr.loadBuiltinSrgb();

// Transform sRGB red to CIEXYZ D50
const transform = mgr.createTransform(srgb, srgb);
const xyz = transform.apply([1, 0, 0]);
// → [0.4361, 0.2225, 0.0139]

// Load a real output profile (e.g. FOGRA39)
const fogra = await mgr.loadProfile('/path/to/FOGRA39.icc');
const toCmyk = mgr.createTransform(srgb, fogra, 'perceptual');
const cmyk = toCmyk.apply([1, 0, 0]);
// → roughly [0, 0.85, 0.72, 0.01]

// Get OutputIntent descriptor for PDF/X embedding
const intent = mgr.getOutputIntent(fogra, 'FOGRA39');
// intent.profile.bytes — embed in PDF OutputIntent stream

API

createColorManager(): ColorManager

Factory. Returns a ColorManager instance with a profile cache.

ColorManager

| Method | Description | |--------|-------------| | loadBuiltinSrgb() | Returns (and caches) the synthesized sRGB IEC61966-2.1 profile | | loadProfile(path) | Reads, parses, and caches an ICC profile from disk | | createTransform(src, dest, intent?) | Creates a compiled ColorTransform between two profiles | | getOutputIntent(profile, condition) | Returns { profile, condition } for PDF/X OutputIntent |

ColorTransform

interface ColorTransform {
  apply(input: number[]): number[];  // values in [0, 1]
}

ColorProfile

The parsed profile type (returned by loadProfile / loadBuiltinSrgb):

interface ColorProfile {
  name: string;
  colorSpace: 'RGB' | 'CMYK' | 'Lab' | 'Gray';
  pcs: 'XYZ' | 'Lab';
  whitePoint: XYZValue;
  matrix?: { r, g, b: XYZValue };        // RGB matrix profiles
  trc?: [TrcCurve, TrcCurve, TrcCurve];  // tone curves
  a2b0?: Mft2Tag;                         // device→PCS LUT
  b2a0?: Mft2Tag;                         // PCS→device LUT
  bytes: Uint8Array;                      // raw ICC bytes for PDF embedding
}

TaggedColor

The v0.11 integration seam — passed to renderToPdf as a structured fill color:

interface TaggedColor {
  source: RGBColor;                          // original sRGB device value
  transformed: CMYKColor | RGBColor | null;  // result of ICC transform
  profileBytes: Uint8Array;                  // for OutputIntent embedding
}

Note: renderToPdf integration (PdfOptions.iccProfile, TaggedColor fill) is being wired up in paragraf-knuth-plass v0.11, after the document model lands in v0.9.

Profile bundling policy

No ICC profiles are bundled. Reasons:

  • FOGRA39/51 are commercial profiles (FOGRA e.V.)
  • sRGB is synthesized in memory from analytical constants — no file needed
  • Keeps the npm tarball clean and legally unambiguous

Test fixtures: download free ICC profiles from ICC.org at test time.

Architecture

spaces.ts     — RGBColor, CMYKColor, LabColor, TaggedColor
profile.ts    — ICC binary parser (header, tag directory, XYZ/curv/mluc/mft2 tags)
srgb.ts       — buildSrgbProfileBytes() + loadBuiltinSrgb()
lut.ts        — eval1DCurve, evalClutTetrahedral (tetrahedral interp), evalLutMft2
transform.ts  — MatrixTrcTransform, LutTransform, ChainedTransform, createTransform
manager.ts    — ColorManager (profile cache + factory)
index.ts      — public API barrel

Roadmap

| Version | Scope | |---------|-------| | v0.1 (current) | Pure TypeScript: profile parsing, matrix+TRC, tetrahedral LUT, sRGB synthesis | | v0.2 | paragraf-knuth-plass v0.11 integration (TaggedColor fill, PDF/X OutputIntent) | | v0.3 | Rust/WASM via qcms — perf upgrade for batch image pipelines | | v0.4 | CSS Color Level 4 inputs (oklch, display-p3) |