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

shrink

v1.0.0

Published

Shrink your image sizes. Save bandwidth and serve images faster

Downloads

36

Readme

Shrink

Compress and optimize images from the command line

Shrink wraps imagemin to provide a simple CLI and Node.js API for compressing JPEGs, PNGs, GIFs, SVGs, and WebP images using best-in-class tools.

Installation

npm i -g shrink

CLI Usage

shrink <files...> [options]

Options

| Flag | Description | Default | |------|-------------|---------| | -o, --output <dir> | Output directory | shrunk | | -t, --tool <name> | Compression tool (see below) | auto | | -q, --quality <num> | Quality 1–100 (lossy tools) | 85 | | -l, --level <num> | Optimization level (lossless tools) | varies |

Tools

| Name | Supports | Description | |------|----------|-------------| | auto | all | Pick best tool per file type | | mozjpeg | .jpg, .jpeg | Mozilla's JPEG encoder — good quality/speed balance | | guetzli | .jpg, .jpeg | Google's high-quality JPEG encoder (slow) | | pngquant | .png | Lossy PNG compression | | optipng | .png | Lossless PNG optimization | | webp | .jpg, .jpeg, .png | Convert images to WebP format | | gifsicle | .gif | GIF optimizer | | svgo | .svg | SVG optimizer |

Auto tool defaults: .jpg/.jpeg → mozjpeg, .png → pngquant, .gif → gifsicle, .svg → svgo

Examples

# Compress all JPEGs into shrunk/ (auto tool)
shrink *.jpg

# Specify output directory
shrink *.jpg -o compressed/

# Use pngquant at quality 80
shrink photo.png -t pngquant -q 80 -o out/

# Convert JPEGs and PNGs to WebP
shrink *.jpg *.png -t webp -o webp/

# Lossless PNG optimization at level 5
shrink *.png -t optipng -l 5

Node.js API

const shrink = require('shrink');

// Basic usage — auto tool, output to shrunk/
await shrink(['photo.jpg', 'banner.png'], 'output/');

// With options
await shrink(['photo.jpg'], 'output/', {
  tool: 'mozjpeg',
  quality: 75,
});

// Results
const results = await shrink(['*.png'], 'compressed/');
results.forEach(r => console.log(r.destinationPath));

shrink(patterns, outputDir, opts?)

| Parameter | Type | Description | |-----------|------|-------------| | patterns | string \| string[] | File paths or globs | | outputDir | string | Destination directory | | opts.tool | string | Tool name or 'auto' (default) | | opts.quality | number | Quality 1–100 for lossy tools | | opts.level | number | Optimization level for lossless tools |

Returns a Promise<Array> of imagemin result objects, each with a destinationPath property.

Accessing tool metadata

const { TOOLS, AUTO_MAP } = require('shrink');

console.log(TOOLS.mozjpeg.description); // "Mozilla's JPEG encoder..."
console.log(AUTO_MAP['.png']);          // "pngquant"

Development

git clone https://github.com/mohnish/shrink.git
cd shrink
npm install

Tests

npm test

License

MIT © Mohnish Thallavajhula