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

optimize-images-cli

v1.0.3

Published

A CLI tool for compressing and optimizing images.

Readme

Optimize Images CLI

npm version npm downloads license GitHub stars GitHub issues

Optimize Images CLI is a powerful and flexible command-line tool for compressing, resizing, and converting images. It supports modern image formats like WebP and AVIF, making it easy to optimize images for web and app development.

📚 Table of Contents


🚀 Features

  • Convert images to formats like JPEG, PNG, WebP, and AVIF.
  • Resize images with custom dimensions while maintaining aspect ratio.
  • Recursive optimization for nested directories.
  • Watch mode for real-time image optimization.
  • Generate detailed optimization reports.

🛠️ Installation

You can install the CLI globally using npm:

npm install -g optimize-images-cli

🔧 Usage

Run the CLI with the following basic syntax:

optimize-images <input> [options]

Options

| Option | Description | Default | |---------------------|--------------------------------------------------------|------------------| | --output | Output directory for optimized images | ./optimized | | --quality <number>| Image quality (1-100) | 80 | | --format <type> | Convert images to a specific format (jpeg, png, webp, avif) | Preserves original | | --width <number> | Maximum width of images | No resizing | | --height <number> | Maximum height of images | No resizing | | --watch | Watch directory for changes and optimize dynamically | false | | --report | Generate a detailed optimization report | false |


📖 Examples

1. Basic Optimization

Optimize all images in the ./images directory and save them in ./optimized:

optimize-images ./images --output ./optimized --quality 80

2. Convert Images to WebP

Convert all images to the WebP format:

optimize-images ./images --output ./optimized --format webp

3. Resize Images

Resize images to fit within a maximum of 800x600 pixels:

optimize-images ./images --output ./optimized --width 800 --height 600

4. Generate an Optimization Report

Generate a report showing original and optimized file sizes:

optimize-images ./images --output ./optimized --quality 75 --report

5. Watch Mode

Monitor a directory for changes and optimize images dynamically:

optimize-images ./images --output ./optimized --watch

🌲 Directory Structure

The tool preserves the original directory structure in the output folder. For example:

Input Directory:

images/
├── photo1.jpg
├── photo2.png
└── nested/
    └── photo3.jpeg

Output Directory:

optimized/
├── photo1.webp
├── photo2.webp
└── nested/
    └── photo3.webp

🧰 Requirements

  • Node.js (v14.0.0 or higher)
  • NPM (v7.0.0 or higher)

💡 Tips

  • Use the --watch option for real-time optimization during development.
  • Combine resizing (--width, --height) with format conversion (--format) for maximum optimization.

⚠️ Troubleshooting

"Command not found"

If you encounter this error, make sure the CLI is installed globally:

npm install -g optimize-images-cli

📜 License

This project is licensed under the MIT License.


🤝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m "Add feature").
  4. Push to the branch (git push origin feature-name).
  5. Open a pull request.

🚀 Roadmap

Here are some planned features for future releases:

  • Support for GIF and TIFF formats.
  • Multi-threaded optimization for faster performance.
  • Export logs to a file with --log option.
  • Config file support for default options (optimize-images.config.json).

Feel free to suggest new features by opening an issue.

💬 Feedback and Support

If you encounter any issues or have suggestions, feel free to open an issue on GitHub or contact at [email protected].

🔒 Security

If you find any security issues, please report them responsibly by contacting [email protected]. We will address them promptly.

❤️ Support

If you like this project and want to support its development, consider:

  • ⭐ Starring this repository on GitHub.
  • Buying me a coffee.
  • 💬 Sharing this tool with your network.

Your support keeps this project alive and growing!