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.
You can install the CLI globally using npm:
npm install -g optimize-images-cli
Run the CLI with the following basic syntax:
optimize-images <input> [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
|
Optimize all images in the ./images
directory and save them in ./optimized
:
optimize-images ./images --output ./optimized --quality 80
Convert all images to the WebP format:
optimize-images ./images --output ./optimized --format webp
Resize images to fit within a maximum of 800x600 pixels:
optimize-images ./images --output ./optimized --width 800 --height 600
Generate a report showing original and optimized file sizes:
optimize-images ./images --output ./optimized --quality 75 --report
Monitor a directory for changes and optimize images dynamically:
optimize-images ./images --output ./optimized --watch
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
--watch
option for real-time optimization during development.--width
, --height
) with format conversion (--format
) for maximum optimization.If you encounter this error, make sure the CLI is installed globally:
npm install -g optimize-images-cli
This project is licensed under the MIT License.
We welcome contributions! Please follow these steps:
git checkout -b feature-name
).git commit -m "Add feature"
).git push origin feature-name
).Here are some planned features for future releases:
--log
option.optimize-images.config.json
).Feel free to suggest new features by opening an issue.
If you encounter any issues or have suggestions, feel free to open an issue on GitHub or contact at contact@gaurabchhetri.com.np.
If you find any security issues, please report them responsibly by contacting contact@gaurabchhetri.com.np. We will address them promptly.
If you like this project and want to support its development, consider:
Your support keeps this project alive and growing!