A blazing fast, open-source CLI tool built to solve Node.js image processing bottlenecks. Utilizes Worker Threads to batch compress images in parallel, achieving up to 97% file size reduction (JPG to WebP) without blocking the main thread. Distributed via NPM.
Improved core performance metrics by 140% during production refactor.
The Problem
As a full-stack developer, managing unoptimized assets is a frequent pain point. Standard Node.js scripts for image conversion run on a single thread, leaving modern multi-core CPUs mostly idle and making batch processing of high-resolution assets painfully slow.
The Solution
I built NexPress (@codernex/nexpress), a CLI tool architected to maximize hardware efficiency. Instead of processing files sequentially, NexPress implements a Master-Worker architecture using native Node.js Worker Threads.
How it Works:
Main Thread: Scans the target directory and handles CLI argument parsing.
ThreadPool: Dynamically spawns a worker for every available CPU core.
Parallel Execution: Distributes image manipulation tasks (resize, convert, compress) across threads.
Result: Images are converted to optimized WebP format in a fraction of the time compared to single-threaded scripts.
Key Achievement
In benchmark tests, I successfully compressed a 7.4MB raw image to a 0.19MB WebP file—a 97% reduction—with negligible loss in visual quality, all while maintaining a non-blocking CLI experience.
🚀 Multi-Threaded Core: Automatically scales the worker pool to utilize 100% of available CPU cores.
🖼️ Smart Optimization: Converts legacy formats (JPG, PNG) to modern, efficient WebP.
💾 Space Analytics: Calculates and reports real-time disk space savings (in MB) after every run.
📂 Flexible Pathing: engineered to handle both absolute system paths and relative user directories seamlessly.
📦 Zero-Config Usage: Published as a scoped NPM package; runs instantly via npx without requiring global installation.
# Try it instantly without installing
npx @codernex/nexpress --input=./photos --output=./compressed