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

print-sizings

v0.1.0

Published

Standard print sizes (inches, ISO A-series) with helpers to convert any size + DPI to pixel dimensions.

Readme

print-sizings

Standard print sizes as typed constants, plus helpers to turn any size and DPI into pixel dimensions.

  • 98 built-in sizes: landscape, portrait, square, panoramic, and ISO A0–A4
  • Any DPI, with presets for 150, 300 and 600
  • Custom sizes work too: pass any { width, height } in inches
  • Fully typed: size ids autocomplete, and a typo is a compile error
  • No dependencies, ESM-only, tree-shakeable, under 3 kB gzipped

Install

npm install print-sizings

Requires Node 22+ or any modern bundler. The package is ESM-only. From CommonJS on Node 22+, require('print-sizings') works (via require(esm)).

Usage

import { DPI, toPixels, getPrintSize, listPrintSizes } from 'print-sizings';

toPixels('10x8', DPI.STANDARD);
// → { width: 3000, height: 2400, dpi: 300 }

toPixels('a4-portrait', DPI.HIGH);
// → { width: 4961, height: 7016, dpi: 600 }

// Any DPI
toPixels('16x20', 240);
// → { width: 3840, height: 4800, dpi: 240 }

// Custom size in inches
toPixels({ width: 5, height: 7 }, DPI.LOW);
// → { width: 750, height: 1050, dpi: 150 }

getPrintSize('8x10');
// → { id: '8x10', category: 'portrait', orientation: 'portrait',
//     label: '8 × 10 in', width: 8, height: 10 }

// Build a picker: every square size with its pixel size at 300 DPI
listPrintSizes({ category: 'square' }).map((size) => ({
  ...size,
  pixels: toPixels(size, DPI.STANDARD),
}));

API

Constants

| Export | Description | | ---------------------------------------------------------------------- | -------------------------------------------------- | | PRINT_SIZES | Every size as a flat, frozen array of PrintSize | | PRINT_SIZES_BY_CATEGORY | { landscape, portrait, square, panoramic } | | LANDSCAPE_SIZES, PORTRAIT_SIZES, SQUARE_SIZES, PANORAMIC_SIZES | Each category on its own | | PRINT_CATEGORIES | ['landscape', 'portrait', 'square', 'panoramic'] | | DPI | { LOW: 150, STANDARD: 300, HIGH: 600 } | | DPI_PRESETS | [150, 300, 600] | | MM_PER_INCH | 25.4 |

toPixels(size, dpi = 300, options?)

Returns { width, height, dpi } in whole pixels.

  • size: a size id ('10x8'), a PrintSize object, or any { width, height } in inches
  • dpi: any positive, finite number. Defaults to 300.
  • options.rounding: 'round' (the default), 'floor' or 'ceil'

Throws a RangeError for an invalid DPI, and a TypeError for an unknown id.

toPixelsAtPresets(size, options?)

Returns the pixel dimensions at all three presets, keyed by DPI: { 150: {...}, 300: {...}, 600: {...} }.

getPrintSize(id)

Looks up a size by id. With a literal id the return type is exact. With an arbitrary string the return type is PrintSize | undefined.

isPrintSizeId(value)

Type guard that narrows a string to PrintSizeId.

listPrintSizes(filter?)

Lists sizes, optionally filtered. Both filter fields take a single value or an array.

listPrintSizes({ category: 'panoramic', orientation: 'portrait' }); // the tall panoramics
listPrintSizes({ category: ['landscape', 'square'] });

toMillimetres(size)

Converts a size id or { width, height } in inches to millimetres. The result is not rounded.

Types

PrintSize, PrintSizeId, PrintCategory, Orientation, IsoPaperSize, Dimensions, PixelDimensions, DpiPreset, Rounding, ToPixelsOptions, PrintSizeFilter.

interface PrintSize {
  id: PrintSizeId; // '10x8', '8x10', 'a4-portrait', …
  category: PrintCategory; // 'landscape' | 'portrait' | 'square' | 'panoramic'
  orientation: Orientation; // 'landscape' | 'portrait' | 'square' (from the dimensions)
  label: string; // '10 × 8 in', 'A4 (portrait)'
  width: number; // inches
  height: number; // inches
  paper?: IsoPaperSize; // 'A0' … 'A4', ISO sizes only
}

Sizes

Every dimension is in inches and written width × height. An id is {width}x{height}, so 10x8 is landscape and 8x10 is portrait. The panoramic category holds both orientations. Use orientation to tell them apart.

ISO A-series sizes are calculated from their exact millimetre dimensions (A4 = 210 × 297 mm), so they print at the standard pixel sizes: A4 at 300 DPI is 2480 × 3508.

landscape: 10x7, 10x8, 12x10, 12x8, 12x9, 14x10, 14x11, 15x10, 15x12, 16x11, 16x12, 18x12, 20x16, 24x16, 24x20, 30x20, 30x24, 36x24, 40x30, 48x36, 60x40, a4-landscape, a3-landscape, a2-landscape, a1-landscape, a0-landscape

portrait: 7x10, 8x10, 10x12, 8x12, 9x12, 10x14, 11x14, 10x15, 12x15, 11x16, 12x16, 12x18, 16x20, 16x24, 20x24, 20x30, 24x30, 24x36, 30x40, 36x48, 40x60, a4-portrait, a3-portrait, a2-portrait, a1-portrait, a0-portrait

square: 8x8, 9x9, 10x10, 11x11, 12x12, 14x14, 15x15, 16x16, 20x20, 24x24, 30x30, 40x40

panoramic: 12x6, 6x12, 16x8, 8x16, 18x10, 10x18, 20x8, 8x20, 20x10, 10x20, 21x8, 8x21, 24x10, 10x24, 24x13, 13x24, 25x10, 10x25, 26x7, 7x26, 26x12, 12x26, 28x10, 10x28, 28x11, 11x28, 30x10, 10x30, 30x11, 11x30, 30x12, 12x30, 30x15, 15x30

Choosing a DPI

| DPI | Use for | | -------------------- | ---------------------------------------------- | | 150 (DPI.LOW) | Large posters and banners seen from a distance | | 300 (DPI.STANDARD) | Photo and art prints. The usual default. | | 600 (DPI.HIGH) | Fine art, line art, and small text |

Contributing

npm install
npm run lint        # oxlint (npm run lint:fix to autofix)
npm run format      # oxfmt (npm run format:check to verify only)
npm run typecheck   # tsc
npm test            # vitest
npm run check       # all of the above, plus build and package lint (publint + attw)
npm run changeset   # describe your change for the changelog

See RELEASING.md for how releases work.

License

MIT © James Porter