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

slice2pdf

v0.1.0

Published

Smart-slice long screenshots into multi-page PDFs without cutting through text or images (macOS, Apple Vision OCR)

Readme

slice2pdf

Smart-slice long screenshots into multi-page PDFs without cutting through text or images.

Uses Apple Vision OCR to find text-line bounding boxes, then picks page breaks that never bisect any line. Falls back to row-energy heuristics when OCR is unavailable.

Quick Start

# one-off
npx slice2pdf screenshot.png

# install globally
npm install -g slice2pdf
slice2pdf screenshot.png

Produces screenshot.pdf next to the input, paginated at A4 ratio with cuts in blank rows.

Usage

# single image -> single pdf
slice2pdf screenshot.png

# every image in a directory
slice2pdf ~/Desktop

# rename output pdf to the OCR'd first-page title
slice2pdf screenshot.png --rename

# keep the per-page PNG slices for inspection
slice2pdf screenshot.png --keep-pages

# pick interactively from cwd images
slice2pdf

Options

| Flag | Default | Description | |------|---------|-------------| | --out <path> | <input>.pdf | output pdf path | | --rename | off | rename pdf to first-page title (Apple Vision OCR) | | --keep-pages | off | keep <basename>-pages/ slice directory | | --help | | print usage | | --version | | print version |

Subcommands:

| Command | What | |---------|------| | slice2pdf doctor | check that swift, python3 (numpy + Pillow), and img2pdf are installed |

How It Works

  1. Compute row energy (per-row pixel std-dev) for the input image.
  2. Tile the image vertically and run Apple Vision text recognition; merge bboxes back to global coordinates. Tile boundaries snap to blank rows so no text line is split at a seam.
  3. For each ideal A4 cut, search a window for the longest run of rows not covered by any text bbox. Cut at the row inside that run with the lowest content.
  4. Crop into PNGs and assemble with img2pdf (lossless, no JPEG re-encoding).

Cuts are independently audited against the OCR bboxes; the algorithm is verified to produce zero text-bisecting page breaks on real-world long screenshots.

Requirements

  • macOS (uses Apple Vision via Swift)
  • Node >= 20
  • swift (xcode-select --install)
  • python3 with numpy and Pillow (python3 -m pip install --user numpy Pillow)
  • img2pdf (brew install img2pdf)

Run slice2pdf doctor to verify.

License

MIT