The imageOptimizer.sh
script optimizes image files in a specified directory using various tools. It supports PNG, JPEG, and other formats, and can display a progress bar and control sleep duration between optimizations to reduce CPU load. This script helps reduce image file sizes, improving website performance and reducing bandwidth usage.
Ensure the following tools are installed:
pngquant
optipng
jpegoptim
optimizt
Install them using these commands:
sudo apt-get install pngquant optipng jpegoptim
npm install -g optimizt
sudo yum install pngquant optipng jpegoptim
npm install -g optimizt
Clone the repository from GitHub:
git clone https://github.com/machadoug/IdealImageOptimizer.git
cd IdealImageOptimizer
Run the script with:
bash imageOptimizer.sh /path/to/directory
Options:
--verbose
: Display a progress bar with time estimation.--sleep <duration>
: Set sleep duration between optimizations (default is 0.75 seconds).
bash imageOptimizer.sh --verbose --sleep 2 /path/to/directory
DIR="."
: Directory to optimize images in (default is the current directory).VERBOSE=false
: Display a progress bar (default is false).SLEEP_DURATION=0.75
: Sleep duration between optimizations (default is 0.75 seconds).
imageOptimization.log
: Tracks processed files to avoid reprocessing.imageOptimization_errors.log
: Logs errors encountered during optimization.
This script is provided as-is without any warranty. Use at your own risk. See LICENSE for details. This project is licensed under the Apache 2.0 License.
See the NOTICE file for attribution of third-party components and IdealExtensions.com.