A high-performance, multi-threaded command-line tool built with Node.js and TypeScript. It converts and compresses batches of images into efficient WebP format using worker threads for maximum speed.
Tested on a standard machine processing a folder of 111 High-Res Images:
| Metric | Result |
|---|---|
| Total Time | ~4.5 seconds |
| Throughput | ~25 images / sec |
| Success Rate | 100% |
vs. standard single-threaded scripts which typically take 4x-5x longer.
- Multi-threaded Processing: Uses Node.js
worker_threadsto process images in parallel, utilizing all available CPU cores. - Format Conversion: Automatically converts
.jpg,.jpeg, and.pngfiles to optimized.webp. - Smart Path Handling: Supports both absolute system paths and paths relative to your home directory.
- Space Savings: Calculates and displays the amount of disk space saved per image in MB.
- Custom Quality: User-definable compression quality (1-100).
- Robust Error Handling: Graceful shutdowns and detailed error logging.
You can use NexPress in three ways:
This installs the @codernex/nexpress command system-wide.
npm install -g @codernex/nexpress
Use it immediately without installing.
npx @codernex/nexpress --input=Desktop/photos --output=Desktop/compressed
# Clone the repository
git clone https://github.com/codernex/nexpress
cd nexpress
# Install dependencies
npm install
# Build the project
npm run build
# Link globally for testing
npm link
If installed globally or linked, simply run nexpress:
nexpress --input=<path> --output=<path> [options]
NexPress is smart about file paths. You can provide:
- Relative Paths (from User Home):
If you type
Desktop/images, the tool looks in~/Desktop/images(Linux/Mac) orC:\Users\You\Desktop\images(Windows).
nexpress --input=Desktop/raw --output=Desktop/processed
- Absolute Paths: You can also provide the full system path.
nexpress --input=/home/user/Downloads/pics --output=/var/www/html/assets
| Option | Required | Description | Default |
|---|---|---|---|
--input |
✅ | Source folder path (Absolute or relative to Home). | N/A |
--output |
✅ | Destination folder path. | N/A |
--quality |
❌ | Compression quality (1-100). | 80 |
--help |
❌ | Displays the help menu. | N/A |
Standard Compression (Default Quality: 80)
nexpress --input=Photos --output=CompressedPhotos
High Compression (Maximum Space Saving)
nexpress --input=Desktop/Wallpapers --output=Desktop/WebP_Small --quality=50
High Quality (Near Lossless)
nexpress --input=/mnt/data/raw --output=/mnt/data/optimized --quality=95
If you want to contribute or modify the code:
- Clone and Install:
git clone https://github.com/codernex/nexpress
npm install
- Run in Development Mode:
You can run the script directly using
ts-node.
# Run directly without building
npx ts-node src/index.ts --input=TestIn --output=TestOut
The tool uses a Main Thread -> Worker Pool architecture:
- Main Thread: Scans the input directory and creates a queue of image processing jobs.
- Worker Threads: Each CPU core gets a worker. The main thread distributes jobs to workers dynamically.
- Sharp: Inside the worker, the
sharplibrary handles the actual image buffer manipulation and WebP conversion.
This project is licensed under the MIT License.
