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

sinter-js

v1.0.2

Published

Browser-side image compression with format conversion, resizing, quality control, and size targeting.

Downloads

230

Readme


Sinter is a browser-side image compression library for apps that need image files smaller before upload, preview, or download. It takes a browser File, applies the options you choose, and returns a compressed image Blob.

  • JPEG, PNG, WebP, AVIF, BMP
  • Keep the input format or convert to another supported format
  • Resize, quality control, and best-effort file size targeting
  • Runs compression off the main UI flow in supported browsers
  • Safe to import in SSR-capable apps; compression runs on the client

Install

npm install sinter-js

Basic Usage

import { sinter } from "sinter-js";

const blob = await sinter()
  .toFormat("webp")
  .maxQuality(80)
  .dimensions({ width: 1200 })
  .compress(file);

Pipeline settings can be reused:

const pipeline = sinter()
  .toFormat("webp")
  .maxQuality(80)
  .dimensions({ width: 1200 });

const firstBlob = await pipeline.compress(firstFile);
const secondBlob = await pipeline.compress(secondFile);

API

Start with sinter(), choose an output format policy, then add any compression options before calling compress(file).

await sinter()
  .allowFormats(["avif", "webp"], "webp")
  .codecOptions({ webp: { lossless: false } })
  .maxQuality(80)
  .dimensions({ width: 1200 })
  .size(1, "MB")
  .timeout(30)
  .compress(file);

Format

| Method | Description | |--------|-------------| | keepFormat() | Use the input format for the output | | toFormat(format) | Encode to one output format | | allowFormats(allowed, fallback) | Keep the input format when it is allowed; otherwise use fallback |

Supported formats:

"jpeg" | "png" | "webp" | "avif" | "bmp"

Compression

| Method | Description | |--------|-------------| | codecOptions(options) | Set encoder options for formats this pipeline can produce | | maxQuality(n) | Set the maximum quality from 1 to 100 | | dimensions({ width?, height? }) | Resize within the given bounds while preserving aspect ratio | | size(value, unit) | Try to fit the output under a target size; unit must be "KB" or "MB" | | timeout(seconds) | Reject if compression takes longer than the limit | | compress(file) | Run the pipeline and return a Blob |

Codec Options

sinter()
  .toFormat("avif")
  .codecOptions({ avif: { speed: 4 } })
  .compress(file);

| Format | Options | |--------|---------| | jpeg | { progressive?: boolean } | | webp | { lossless?: boolean } | | avif | { speed?: number } | | png | None | | bmp | None |

Behavior

  • Input format is detected from file bytes, not the file extension.
  • size() is best effort. Some images may not fit the requested target.
  • For lossy output formats, size fitting lowers quality before reducing dimensions.
  • maxQuality() does not change BMP output quality.
  • If same-format compression would make the file larger, Sinter returns the original bytes when no resize or size target was requested.

Browser And SSR

Sinter can be imported in SSR-capable apps because it does not access browser globals at import time.

Call compress(file) from browser client code. Other runtimes are not part of the public API and may reject with SinterCodecError.

Errors

import { SinterValidationError, SinterCodecError } from "sinter-js";

| Error | When | |-------|------| | SinterValidationError | Invalid input, such as an empty file or an out-of-range option | | SinterCodecError | Compression failed, timed out, or ran outside the public browser API path |

License

MIT. Third-party notices are included in packages/module/THIRD_PARTY_NOTICES.md.