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

resizerelay

v0.1.1

Published

Official Node.js SDK for the Resize Relay API — resize images to exact KB file sizes and exact dimensions (passport, exam, and marketplace specs).

Readme

Resize Relay — Node.js SDK

npm version license

Official Node.js client for the Resize Relay API — resize images to exact KB file sizes and exact pixel dimensions — the specs that passport portals, government exam forms, and marketplaces actually enforce.

  • Exact-size engine — binary-searches encoder quality to hit a KB ceiling (and a floor, for "20–50 KB" style bands), reducing resolution only when unavoidable.
  • Exact-dimension cropsfit: "cover" produces exactly width×height with a centered, saliency-aware crop (no stretching).
  • Zero dependencies — uses the global fetch in Node 18+.
  • Free tier — 500 resizes/month per key. Create a key →

Install

npm install resizerelay

Quickstart

const { ResizeRelay } = require("resizerelay");
// or: import ResizeRelay from "resizerelay";

const client = new ResizeRelay(process.env.RESIZERELAY_API_KEY);

// Job-portal photo: exactly 600×600, under 100 KB
await client.resizeToFile("photo.jpg", "photo-600.jpg", {
  targetKb: 100,
  width: 600,
  height: 600,
  fit: "cover",
});

// Exam signature: 350×200 JPEG between 10 and 20 KB
const result = await client.resize("signature.png", {
  targetKb: 20,
  minKb: 10,
  width: 350,
  height: 200,
  fit: "cover",
  format: "jpeg",
});
console.log(result.contentType, result.buffer.length, "bytes");
console.log("quota:", result.quota); // { limit: 500, used: 12, remaining: 488 }

Input can be a file path, Buffer, Uint8Array, ArrayBuffer, or Blob. The result's buffer is the resized image; quota headers are parsed for you.

Options

| Option | Type | Description | | ---------- | --------------------- | ----------- | | targetKb | number | Max output size in KB. | | targetMb | number | Max output size in MB (overrides targetKb). | | minKb | number | Min output size in KB (compliance bands). | | width | number | Output width in px. | | height | number | Output height in px. | | fit | "cover" \| "inside" | cover = exact width×height via centered crop; inside = fit within, keep aspect (default). | | format | "jpeg" \| "png" \| "webp" | Output format (default jpeg). | | quality | number | Encoder quality 0–1 (default 0.92). |

Error handling

All non-2xx responses throw a ResizeRelayError with status, requestId, and (for rate limits) retryAfter:

const { ResizeRelayError } = require("resizerelay");

try {
  await client.resize("photo.jpg", { targetKb: 50 });
} catch (err) {
  if (err instanceof ResizeRelayError) {
    console.error(err.status, err.message, "request:", err.requestId);
    if (err.status === 429 && err.retryAfter) {
      // burst limit — back off err.retryAfter seconds
    }
  }
}

| Status | Meaning | | ------ | ------- | | 400 | Bad input (missing file, unreachable target). | | 401 | Missing, invalid, or revoked API key. | | 413 | Image larger than 25 MB. | | 429 | Burst rate limit (120 req/min) or monthly quota reached. |

Links

License

MIT