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

optiweb

v1.3.1

Published

A powerful CLI image optimization tool compliant with Google PageSpeed standards. Supports WebP, multiple sizes, responsive images, and lossless/nearLossless modes.

Readme

optiweb

npm version MIT License

A powerful CLI image optimization tool compliant with Google PageSpeed standards. Supports WebP, multiple sizes, responsive images, and lossless/nearLossless modes.

Features

  • Optimizes JPG and PNG images according to PageSpeed standards
  • Optionally converts images to WebP format
  • Provides optimal compression while preserving quality
  • Preserves folder structure and outputs to the same structure
  • Copies non-image files as-is
  • If a WebP file with the same name exists, only the WebP is copied (JPG/PNG is skipped)
  • Option to ignore specific files or folders
  • Ability to resize images to specific or maximum dimensions
  • Generate multiple outputs in different sizes from a single image (responsive images)
  • CLI options for WebP lossless and nearLossless modes

Installation

npm install -g optiweb

For local development:

git clone https://github.com/yourusername/optiweb.git
cd optiweb
npm install
npm link

Usage

Basic usage:

optiweb --input <input-folder> --output <output-folder>

All options:

optiweb --input <input-folder> --output <output-folder> [options]

Options

| Option | Description | Default | | ----------------------- | -------------------------------------------------------- | -------- | | --input, -i | Input folder (required) | - | | --output, -o | Output folder (required) | - | | --webp, -w | Convert to WebP format | false | | --quality, -q | General quality level (0-100) | 85 | | --jpg-quality | Quality for JPG (0-100) | 85 | | --png-quality | Quality for PNG (0-100) | 85 | | --webp-lossless | Enable WebP lossless mode | false | | --webp-near-lossless | Enable WebP nearLossless mode | false | | --skip-existing, -s | Skip files that already exist | false | | --verbose, -v | Verbose output | false | | --ignore <patterns> | Ignore file/folder patterns (comma-separated glob) | - | | --resize <dimensions> | Resize to fixed size (e.g. 800x600) | - | | --resize-mode <mode> | Resize mode | cover | | --max-width <width> | Maximum width, proportional resize | - | | --max-height <height> | Maximum height, proportional resize | - | | --sizes <sizes> | Multiple sizes (comma-separated, e.g. 180,300,500) | - | | --suffix-pattern <p> | Suffix pattern for file names | -{width} | | --only-resize | Only resize, do not optimize | false | | --slug | Convert file names to slug format (lowercase, no spaces) | false | | --help, -h | Show help | - |

Examples

Optimize JPG and PNG files:

optiweb --input ./images --output ./optimized

Optimize and convert to WebP:

optiweb --input ./images --output ./optimized --webp

Use higher quality:

optiweb --input ./images --output ./optimized --quality 90

Ignore specific files and folders:

optiweb --input ./images --output ./optimized --ignore "node_modules/**,*.svg,temp/*"

Resize images to a specific size:

optiweb --input ./images --output ./optimized --resize 800x600

Limit maximum width (keep aspect ratio):

optiweb --input ./images --output ./optimized --max-width 1200

Resize and convert to WebP:

optiweb --input ./images --output ./optimized --resize 800x600 --webp

Generate responsive images in multiple sizes:

optiweb --input ./images --output ./optimized --sizes "200,400,800,1200" --webp

Use a custom suffix pattern for multi-size output:

optiweb --input ./images --output ./optimized --sizes "200,400,800" --suffix-pattern "_w{width}"

Only resize, do not optimize:

optiweb --input ./images --output ./optimized --sizes "200,400,800" --only-resize

Use WebP lossless and nearLossless modes:

optiweb --input ./images --output ./optimized --webp --webp-lossless --webp-near-lossless

Resize Modes

Available values for --resize-mode:

  • cover: Fills the target size, cropping if necessary (default)
  • contain: Fits the image within the target size, may add padding
  • fill: Stretches the image to fill the target size, may distort aspect ratio
  • inside: Fits the image inside the target size
  • outside: Fills the target size from the outside

Suffix Pattern

The --suffix-pattern option determines how the size is added to the file name. The default is "-{width}", which appends the width to the file name:

  • logo.pnglogo-200.png, logo-400.png, etc.

Other examples:

How It Works

  1. Scans all files in the input folder
  2. Ignores files matching the ignore patterns
  3. Skips JPG/PNG files if a WebP with the same name exists
  4. Detects JPG and PNG files
  5. If multi-size is requested, generates outputs for each specified size
  6. If single-size is requested, resizes images to the specified dimensions
  7. Uses the Sharp library to optimize files (unless only resizing)
  8. Converts to WebP if the option is enabled
  9. Saves results to the output folder, preserving the input folder structure
  10. Copies non-image files directly

Performance

This tool uses optimization methods recommended by Google PageSpeed Insights:

  • MozJPEG algorithm for JPG files
  • Optimum compression for PNG files
  • Quality/size optimization for WebP

Requirements

  • Node.js 14.0 or higher

License

MIT