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.
- Features
- Installation
- Usage
- Examples
- Directory Structure
- Requirements
- Tips
- License
- Contributing
- Feedback and Support
- 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.
You can install the CLI globally using npm:
npm install -g optimize-images-cliRun 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 80Convert all images to the WebP format:
optimize-images ./images --output ./optimized --format webpResize images to fit within a maximum of 800x600 pixels:
optimize-images ./images --output ./optimized --width 800 --height 600Generate a report showing original and optimized file sizes:
optimize-images ./images --output ./optimized --quality 75 --reportMonitor a directory for changes and optimize images dynamically:
optimize-images ./images --output ./optimized --watchThe 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
- Node.js (v14.0.0 or higher)
- NPM (v7.0.0 or higher)
- Use the
--watchoption for real-time optimization during development. - Combine resizing (
--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-cliThis project is licensed under the MIT License.
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-name). - Commit your changes (
git commit -m "Add feature"). - Push to the branch (
git push origin feature-name). - Open a pull request.
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
--logoption. - Config file support for default options (
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 [email protected].
If you find any security issues, please report them responsibly by contacting [email protected]. We will address them promptly.
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!