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

webimg-cli

v1.0.1

Published

A fast and simple CLI to optimize images and videos for the web. Compress, resize, and convert to modern formats like WebP, AVIF, and WebM.

Downloads

206

Readme

webimg-cli

A fast and simple Node.js CLI to batch optimize images and videos for the web. Compress, resize, and convert to modern formats like WebP, AVIF, and WebM in a single command.

Built for photographers and developers who need to quickly turn high-resolution exports into lightweight, web-ready files.

Features

  • Batch processing -- process entire folders of images or videos at once
  • Image optimization -- compress and convert PNG, JPEG, WebP, and AVIF with sharp
  • Video optimization -- convert MP4 to optimized MP4 + WebM with ffmpeg (bundled)
  • Smart resizing -- resize to max width/height while preserving aspect ratio, never upscales
  • Metadata stripping -- removes EXIF and other unnecessary data
  • Progress bar -- real-time progress with ETA for large batches
  • Concurrent processing -- processes multiple images in parallel for speed
  • Zero config ffmpeg -- ffmpeg and ffprobe are bundled, no system install needed

Installation

npm install -g webimg-cli

Or use directly with npx (no install required):

npx webimg-cli --images -i ./photos -o ./web -f webp -w 2000

Usage

The CLI has two modes: --images for image files and --video for video files.

Images

Convert and optimize image files. Requires --format to specify the output format.

# Convert all images to WebP, max 2000px wide
webimg-cli --images -i ./photos -o ./web -f webp -w 2000

# Convert to AVIF with custom quality
webimg-cli --images -i ./raw -o ./optimized -f avif -q 50

# Resize to fit within 1920x1080, output as JPEG
webimg-cli --images -i ./input -o ./output -f jpeg -w 1920 --height 1080

Supported input formats: PNG, JPEG/JPG, WebP, AVIF

Supported output formats: PNG, JPEG, WebP, AVIF

Videos

Optimize video files. Each input MP4 produces two output files: an optimized MP4 and a WebM version. No --format flag needed.

# Optimize all MP4 videos, scale down to 1920px wide
webimg-cli --video -i ./videos -o ./web -w 1920

# Optimize without resizing
webimg-cli --video -i ./videos -o ./web

Input: MP4

Output: Optimized MP4 (H.264 + AAC) and WebM (VP9 + Opus)

Options

| Flag | Alias | Description | Required | |------|-------|-------------|----------| | --images | | Process image files | One of --images or --video | | --video | | Process video files | One of --images or --video | | --input | -i | Input directory | Yes | | --output | -o | Output directory (created if missing) | Yes | | --format | -f | Output image format: png, jpeg, webp, avif | Only with --images | | --width | -w | Max width in pixels | No | | --height | | Max height in pixels | No | | --quality | -q | Quality level (images: 1-100, video: CRF) | No | | --concurrency | | Parallel workers (default: 4) | No |

Default quality settings

Images

| Format | Quality | Notes | |--------|---------|-------| | JPEG | 80 | Uses mozjpeg for smaller files | | WebP | 80 | Good balance of quality and size | | AVIF | 60 | AVIF compresses more efficiently at lower values | | PNG | Level 9 | Maximum compression with palette optimization |

Videos

| Format | Codec | Audio | CRF | Notes | |--------|-------|-------|-----|-------| | MP4 | H.264 | AAC 128k | 23 | movflags +faststart for web streaming | | WebM | VP9 | Opus 128k | 30 | Excellent compression for modern browsers |

Example workflow

project/
  photos/
    hero.png         (8.2 MB)
    portrait.jpg     (5.1 MB)
    landscape.png    (12.4 MB)

  videos/
    promo.mp4        (48 MB)
webimg-cli --images -i ./photos -o ./web -f webp -w 2000
webimg-cli --video -i ./videos -o ./web -w 1920
web/
  hero.webp          (180 KB)
  portrait.webp      (120 KB)
  landscape.webp     (240 KB)
  promo.mp4          (12 MB)
  promo.webm         (9 MB)

Requirements

  • Node.js >= 18

Development

git clone https://github.com/tadeuszderuijter/webimg-cli.git
cd webimg-cli
npm install
npm run build
npm run start -- --images -i ./photos -o ./web -f webp -w 2000

License

Apache-2.0