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

one-image-optimizer

v1.0.2

Published

Optimize PNG, JPEG images by compressing them and converting them to webp format.

Downloads

293

Readme

🚀 One Image Optimizer

A powerful npm package tool to automatically compress, rename, and convert your images to WebP format.

✨ Features

  • 🗜️ Auto-compress images larger than 1MB
  • 🏷️ Smart rename images based on their folder names
  • 🔄 Convert to WebP for optimal web performance
  • 🗑️ Empty folders utility to clean up directories
  • ⚙️ Configurable settings via config file
  • Safe - Asks for confirmation before making changes

📦 Installation

npm install one-image-optimizer

After installation, a configuration file one-image-optimizer.config.js will be automatically created in your project root.

🛠️ Setup

  1. Edit the config file that was created in your project root:
// one-image-optimizer.config.js
module.exports = {
  ROOT_FOLDER: './assets/images',  // 👈 Change this to your images folder
  COMPRESS_THRESHOLD_MB: 1,
  MAX_WIDTH: 1920,
  MAX_HEIGHT: 1080,
  WEBP_QUALITY: 80,
  JPEG_QUALITY: 75,
  IMAGE_EXTENSIONS: ['.jpg', '.jpeg', '.png', '.webp', '.gif', '.bmp', '.tiff']
};
  1. Set your ROOT_FOLDER to point to your images directory

🎯 Usage

Full Optimization (All Steps)

Run all optimization steps in sequence:

npx one-image-optimizer

Or if installed globally:

one-image-optimizer

This will:

  1. ✅ Compress all images larger than 1MB
  2. ✅ Rename images based on folder names
  3. ✅ Convert all images to WebP format

Note: You'll be asked to confirm before the process starts.

Individual Commands

Run specific optimization steps:

# Compress images only
npx oio-compress

# Convert to WebP only
npx oio-webp

# Rename images only
npx oio-rename

# Empty all files in folders (⚠️ destructive!)
npx oio-empty

Tip: You can also install globally to use shorter commands:

npm install -g one-image-optimizer

# Then use without npx:
one-image-optimizer
oio-compress
oio-webp
oio-rename

📋 How It Works

1. Compression

  • Scans your ROOT_FOLDER for images larger than COMPRESS_THRESHOLD_MB
  • Compresses them while maintaining quality
  • Resizes to max dimensions if needed

2. Renaming

  • Renames images based on their parent folder name
  • Format: {foldername}image1.jpg, {foldername}image2.jpg, etc.
  • Removes spaces from folder names

3. WebP Conversion

  • Converts all images to WebP format
  • Deletes original files after successful conversion
  • Removes duplicate non-WebP versions

4. Empty Folders

  • Deletes all files within the target folder
  • Keeps folder structure intact
  • ⚠️ Use with caution!

⚙️ Configuration Options

| Option | Default | Description | |--------|---------|-------------| | ROOT_FOLDER | './assets/images' | Root directory containing your images | | COMPRESS_THRESHOLD_MB | 1 | Compress images larger than this (in MB) | | MAX_WIDTH | 1920 | Maximum width for compressed images | | MAX_HEIGHT | 1080 | Maximum height for compressed images | | WEBP_QUALITY | 80 | WebP compression quality (0-100) | | JPEG_QUALITY | 75 | JPEG compression quality (0-100) | | IMAGE_EXTENSIONS | ['.jpg', '.jpeg', ...] | Supported image formats |

🔒 Safety Features

  • ✅ Confirmation prompt before running full optimization
  • ✅ Extra confirmation for destructive operations (empty-folders)
  • ✅ Clear warnings about what will be changed
  • ✅ Validates config file and paths before running

📝 Example Workflow

# 1. Install the package
npm install one-image-optimizer

# 2. Edit one-image-optimizer.config.js
# Set ROOT_FOLDER to your images directory

# 3. Run full optimization
npx one-image-optimizer

# 4. Or run individual commands
npx oio-compress
npx oio-webp
npx oio-rename

🐛 Troubleshooting

Config file not found

  • Make sure one-image-optimizer.config.js exists in your project root
  • Run npm install again to recreate it

Path does not exist

  • Check that ROOT_FOLDER in your config points to a valid directory
  • Use relative paths from your project root (e.g., ./assets/images)

Permission errors on Windows

  • The tool includes Windows file lock handling
  • If issues persist, close any programs that might be using the images

📄 License

MIT

🤝 Contributing

Issues and pull requests are welcome!


Made with ❤️ for optimizing images