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

image-size-cli

v1.0.0

Published

CLI tool to resize images — supports BMP and PPM, bilinear & nearest-neighbor interpolation, aspect-ratio-aware fit modes. Zero dependencies.

Readme

image-size-cli

Resize images from the command line. Zero dependencies — only Node.js built-ins.

Supports BMP and PPM formats with bilinear and nearest-neighbor interpolation.

Install

npm install -g image-size-cli

Usage

image-size-cli <input> [options]
# Resize to 800px wide (aspect ratio preserved)
image-size-cli photo.bmp --width 800

# Resize to exactly 400×300 (stretches if needed)
image-size-cli photo.bmp -w 400 -h 300 --fit=fill

# Scale to 50%
image-size-cli photo.bmp --scale 50 -o small.bmp

# Cover a 200×200 thumbnail box
image-size-cli photo.bmp -w 200 -h 200 --fit=cover -o thumb.bmp

# Nearest-neighbor (pixel art / icons)
image-size-cli sprite.bmp --scale 400 --algorithm nearest

# Cross-format: BMP → PPM
image-size-cli photo.bmp --width 320 -o photo.ppm

Options

| Flag | Short | Description | |---|---|---| | --width <px> | -w | Target width in pixels | | --height <px> | -h | Target height in pixels | | --scale <pct> | -s | Scale percentage (e.g. 50 = 50%) | | --output <path> | -o | Output file (default: <name>_resized.<ext>) | | --fit <mode> | -f | contain · cover · fill (default: contain) | | --algorithm <a> | -a | bilinear (default) · nearest | | --help | | Show help |

Fit modes

| Mode | Behaviour | |---|---| | contain | Fit inside the target box, preserve aspect ratio (may add empty edges) | | cover | Cover the target box, preserve aspect ratio (may overflow) | | fill | Stretch to exact target dimensions |

Supported formats

| Format | Read | Write | |---|---|---| | BMP (24-bit, 32-bit) | ✓ | ✓ (24-bit) | | PPM (P6 binary) | ✓ | ✓ |

API

Use as a library:

import { resizeImage, calculateDimensions, bilinear } from 'image-size-cli';

// High-level (reads + writes files)
const result = resizeImage('photo.bmp', 'small.bmp', { width: 400, fit: 'contain' });
console.log(result); // { srcWidth: 1920, srcHeight: 1080, dstWidth: 400, dstHeight: 225 }

// Dimension calculator (pure)
const dims = calculateDimensions(1920, 1080, { width: 800 });
// { width: 800, height: 450 }

calculateDimensions(1920, 1080, { width: 200, height: 200, fit: 'cover' });
// { width: 200, height: 113 }  ← both axes ≥ 200

// Low-level pixel resize (pure, Uint8Array → Uint8Array)
import { parseBmp, encodeBmp, bilinear, nearestNeighbor } from 'image-size-cli';
import { readFileSync, writeFileSync } from 'fs';

const src = parseBmp(readFileSync('photo.bmp'));
const px  = bilinear(src.pixels, src.width, src.height, 320, 240, 3);
writeFileSync('out.bmp', encodeBmp(320, 240, px));

CommonJS

const { resizeImage, calculateDimensions } = require('image-size-cli');

How it works

Bilinear interpolation — samples 4 neighbouring pixels and blends them proportionally. Smooth results for photos and artwork.

Nearest-neighbor — copies the closest pixel. Sharp, blocky results — ideal for pixel art, icons, or sprites.

BMP is parsed/written manually (14-byte file header + 40-byte BITMAPINFOHEADER). Supports 24-bit and 32-bit input, always writes 24-bit.

PPM (P6 binary) is a trivial format: ASCII header + raw RGB bytes. Fast and simple.

License

MIT