Image Optimizer is a Node.js application for resizing and optimizing images while maintaining directory structure integrity.
/image-optimizer
├── index.js # Main script for image processing
├── package.json # Project configuration and dependencies
└── README.md # Project documentation
-
Clone the repository:
git clone https://github.com/thakurcoderz/image-optimizer.git cd image-optimizer -
Install dependencies:
npm install
-
Configure
index.js:- Update
inputDirandoutputDirvariables with your source and destination folder paths. - Adjust
maxWidthandmaxHeightfor image resizing as needed. - Modify
allowedFormatsto include or exclude image formats according to your requirements.
- Update
-
Run the script:
npm start
inputDir: Path to the directory containing original images.outputDir: Path to the directory where optimized images will be saved.maxWidth: Maximum width for resized images.maxHeight: Maximum height for resized images.allowedFormats: Array of allowed image formats to process (e.g.,['jpg', 'jpeg', 'png', 'webp', 'tiff']).