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

beautiful-image

v1.1.0

Published

Compress and optimize images with minimal quality loss in the browser or on the server. Powered by Rust/WASM with zero native dependencies.

Readme

beautiful-image

Compress and optimize images with minimal quality loss in the browser or on the server. Powered by Rust/WASM with zero native dependencies.

How it works

Most tools that compress images do it at the cost of visible quality degradation. beautiful-image combines resize, sharpening, and JPEG encoding tuned to produce the smallest file size while keeping the image looking sharp and clean.

  • Browser uses the native Canvas API for fast GPU-accelerated decode and resize, then hands off to WASM for sharpening and JPEG encoding
  • Node.js runs the full pipeline in WASM (decode, resize, filters, encode), making it ideal for serverless environments like AWS Lambda or Google Cloud Functions with no native dependencies

Install

npm install beautiful-image

Browser

<input type="file" id="upload" accept="image/*" />
<img id="preview" />
import { image } from 'beautiful-image'

const input = document.getElementById('upload') as HTMLInputElement

input.addEventListener('change', async () => {
  const file = input.files?.[0]
  if (!file) return

  const result = await image(file)
    .resize(1200)
    .sharpen()
    .toJpeg(80)

  // result.blob              optimized image as Blob
  // result.originalSize      original size in bytes
  // result.optimizedSize     new size in bytes
  // result.compressionRatio  0.85 = 85% smaller
  // result.width / result.height

  document.getElementById('preview').src = URL.createObjectURL(result.blob)
})

For a full working demo see examples/web-demo.

Node.js

import { image } from 'beautiful-image/node'
import { readFileSync, writeFileSync } from 'node:fs'

const input = readFileSync('./photo.jpg')

const result = await image(input)
  .resize(1200)
  .sharpen()
  .toJpeg(80)

writeFileSync('./optimized.jpg', result.data)

// result.data              optimized image as Buffer
// result.originalSize      original size in bytes
// result.optimizedSize     new size in bytes
// result.compressionRatio  0.85 = 85% smaller

Lambda + S3 example

import { S3Client, GetObjectCommand, PutObjectCommand } from '@aws-sdk/client-s3'
import { image } from 'beautiful-image/node'

const s3 = new S3Client({})

export const handler = async (event: any) => {
  const bucket = event.Records[0].s3.bucket.name
  const key = decodeURIComponent(event.Records[0].s3.object.key)

  const { Body } = await s3.send(new GetObjectCommand({ Bucket: bucket, Key: key }))
  const input = Buffer.from(await Body!.transformToByteArray())

  const result = await image(input).resize(1200).sharpen().toJpeg(80)

  await s3.send(new PutObjectCommand({
    Bucket: bucket,
    Key: `optimized/${key}`,
    Body: result.data,
    ContentType: 'image/jpeg',
  }))
}

API

All methods are available in both browser and Node.js:

image(file)
  .resize(width)        // resize maintaining aspect ratio
  .sharpen(sigma)       // default 1.5  subtle to strong
  .blur(sigma)          // gaussian blur
  .brightness(value)    // -100 to 100
  .contrast(value)      // -100 to 100
  .hueRotate(degrees)   // -180 to 180
  .grayscale()          // black & white
  .invert()             // invert colors
  .toJpeg(quality)      // 1-100

Use Cases

  • E-commerce Optimize product images before upload, saving storage and bandwidth
  • CMS/Blogs Process images on the client before saving, no server needed
  • Social apps Compress and filter photos before posting
  • Lambda/Cloud Functions Automatically optimize images on upload to S3 or cloud storage
  • Blurred previews Generate blurred thumbnails before unlocking content

TODO

  • [ ] More filters (sepia, vignette, noise)
  • [ ] Crop
  • [ ] Export to WebP/PNG
  • [ ] Presets
  • [ ] Web Worker support
  • [ ] Batch processing
  • [ ] getImageDimensions() return width/height from Node.js pipeline (image::image_dimensions() reads only the header, no full decode)