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

imagetune

v2.0.0

Published

Tiny zero-dependency browser library for client-side image resizing, cropping, and format conversion.

Downloads

307

Readme

ImageTune

Tiny zero-dependency browser library for client-side image resizing, cropping, and format conversion. Takes a File (typically from <input type="file">) and returns an encoded Blob so apps can downscale and re-encode large photos before upload — saving bandwidth, server processing time, and storage.

v2 highlights: TypeScript types, ESM + CJS + UMD builds, WebP output, OffscreenCanvas decoding, AbortSignal cancellation, and proper rejection of malformed inputs. See Migrating from v1.

npm install imagetune
# or: pnpm add imagetune  /  yarn add imagetune  /  bun add imagetune

Usage

import { tune } from 'imagetune';

const file = (document.querySelector<HTMLInputElement>('#file'))!.files![0];

const blob = await tune(file, {
  type: 'webp',
  quality: 80,
  width: 250,
  height: 250,
  mode: 'crop',
});

// Preview:
preview.src = URL.createObjectURL(blob);

// Or upload directly:
const fd = new FormData();
fd.append('image', blob, 'avatar.webp');
await fetch('/upload', { method: 'POST', body: fd });

Need a base64 data URL (v1 behavior) instead of a Blob?

import { tuneToDataURL } from 'imagetune';
const dataUrl = await tuneToDataURL(file, { type: 'webp', quality: 80 });

Drop-in <script> tag (UMD/IIFE build, exposes window.ImageTune):

<script src="https://unpkg.com/imagetune"></script>
<script>
  ImageTune.tune(file, { type: 'webp', quality: 80 }).then(blob => { ... });
</script>

Options

| Name | Type | Default | Description | |--------------------|-------------------------------------------------|----------|------------------------------------------------------------| | width | number | 200 | Target width in pixels. | | height | number | 200 | Target height in pixels. | | quality | number (1–100) | 100 | Encoder quality. Ignored for png (lossless). | | type | 'jpeg' \| 'jpg' \| 'png' \| 'webp' | 'jpeg' | Output format. 'jpg' is an alias for 'jpeg'. | | mode | 'scale' \| 'crop' | 'scale'| scale fits inside the box; crop covers and centers. | | smoothingQuality | 'low' \| 'medium' \| 'high' | 'high' | Canvas imageSmoothingQuality. | | signal | AbortSignal | — | Cancel decoding/encoding (e.g. when the input changes). |

Migrating from v1

| Change | Action | |-----------------------------------------|-------------------------------------------------------------------------| | tune() resolves with a Blob | Use URL.createObjectURL(blob) for previews, or tuneToDataURL(). | | gif output removed | It silently fell back to PNG anyway. Pass 'png' (or 'webp'). | | Errors now reject the promise | Add .catch(...) (or wrap in try/await). v1 silently hung instead. | | No more global UMD via bare index.js | Use the unpkg build or import from the package. |

The default options are unchanged; same target dimensions, same JPEG default.

Browser support

Modern evergreen browsers. The library prefers createImageBitmap and OffscreenCanvas, falling back to FileReader + <img> + HTMLCanvasElement when those aren't available.

AVIF input is decoded by every modern browser, so tune() happily accepts AVIF blobs as input. AVIF output is not currently supported in the canvas APIs of any production browser as of early 2026 — canvas.convertToBlob({ type: 'image/avif' }) rejects everywhere — so 'avif' is intentionally absent from the type enum. Pick 'webp' if you want broad encoder support with strong compression.

Cancellation note. Browsers don't expose a way to truly cancel an in-flight createImageBitmap decode or convertToBlob encode. When signal aborts during one of those steps, the promise rejects immediately and any decoded ImageBitmap is .close()d, but the underlying decode/encode work runs to completion in the background. For UI flows where the user is rapidly switching files, this still drops the unwanted result on the floor — just don't expect CPU work to stop instantly.

Development

pnpm install
pnpm dev          # rebuild on change
pnpm test         # vitest
pnpm typecheck
pnpm lint
pnpm build

Open examples/index.html after a build to try it in a browser.

Releases are automated via semantic-release: merge a Conventional Commit to main and a new npm version is published with provenance, a GitHub Release, and an updated CHANGELOG.md.

Authentication uses npm Trusted Publishing (OIDC) — there is no NPM_TOKEN secret. @semantic-release/npm is configured with npmPublish: false, so it bumps package.json but skips publishing; the actual npm publish --provenance --access public runs via @semantic-release/exec and uses the npm CLI's native OIDC flow. The release workflow has id-token: write and the package is configured on npmjs.com to trust this repo's release.yml workflow.

License

ISC. See LICENSE.