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

@resizebento/image-resizer

v1.0.0

Published

Browser-first image resizing and format conversion for JavaScript and TypeScript.

Readme

@resizebento/image-resizer

Browser-first image resizing and format conversion for JavaScript and TypeScript.

Built by ResizeBento.com, a collection of privacy-friendly image tools that process files locally in the browser.

Install

npm install @resizebento/image-resizer

Quick start

import { resizeImage } from '@resizebento/image-resizer';

const input = fileInput.files?.[0];
if (!input) throw new Error('Select an image first');

const result = await resizeImage(input, {
  width: 800,
  height: 600,
  mode: 'crop-to-fit',
  format: 'webp',
  quality: 80,
});

const url = URL.createObjectURL(result.blob);

Resize by percentage

import { resizeImageByPercentage } from '@resizebento/image-resizer';

const result = await resizeImageByPercentage(file, 50, {
  format: 'jpg',
  quality: 85,
});

console.log(result.width, result.height);

Read image dimensions

import { getImageDimensions } from '@resizebento/image-resizer';

const dimensions = await getImageDimensions(file);
console.log(dimensions.width, dimensions.height);

Resize modes

| Mode | Behavior | | --- | --- | | crop-to-fit | Center-crops the source to completely fill the requested dimensions. | | stretch | Stretches the source directly to the requested dimensions. | | add-padding | Fits the complete source inside the requested dimensions and fills the remaining area with a padding color. | | fill-frame | Uses the same centered cover behavior as ResizeBento's Fill Frame mode. |

Output formats

The package can encode:

  • WebP
  • JPG
  • PNG

quality uses a value from 10 to 100 for WebP and JPG. PNG ignores quality because browser canvas PNG encoding does not expose a quality control.

const result = await resizeImage(file, {
  width: 1200,
  height: 630,
  mode: 'add-padding',
  paddingColor: '#ffffff',
  format: 'jpg',
  quality: 90,
});

API

resizeImage(input, options)

Accepts a JPEG, PNG, or WebP Blob or File and returns a resized Blob plus output metadata.

type ResizeImageOptions = {
  width: number;
  height: number;
  mode?: 'crop-to-fit' | 'add-padding' | 'stretch' | 'fill-frame';
  format?: 'webp' | 'jpg' | 'png';
  quality?: number;
  paddingColor?: string;
};

Defaults are exported through imageResizerConfig. The default mode is crop-to-fit, the default output format is webp, and the default quality is 80.

resizeImageByPercentage(input, percentage, options?)

Scales both source dimensions by the supplied percentage. Supported percentages range from 1 to 500.

getImageDimensions(input)

Returns the decoded width and height without resizing the image.

ImageResizerError

Validation, decoding, canvas, and encoding failures throw ImageResizerError. The code property can be used for application-specific error messages.

import { ImageResizerError, resizeImage } from '@resizebento/image-resizer';

try {
  await resizeImage(file, { width: 800, height: 600 });
} catch (error) {
  if (error instanceof ImageResizerError) {
    console.error(error.code);
  }
}

Browser requirements

The package uses modern browser APIs:

  • createImageBitmap
  • Canvas 2D
  • HTMLCanvasElement.toBlob

It has no runtime dependencies and no native binaries.

Privacy

Image processing runs locally in the browser. This package does not upload image content to ResizeBento.

For interactive image tools, visit ResizeBento.com.

License

MIT