.. | ||
README.md |
Bash script to optimize your images and convert them in WebP
Prerequisite
- jpegoptim
- optipng
- WebP
Debian/Ubuntu :
sudo apt install jpegoptim optipng webp -y
Centos 7 :
sudo yum install optipng jpegoptim libwebp-tools -y
What does the script do
- optimize jpg images with jpegoptim
- optimize png images with optipng
- convert jpg & png images in WebP (without deleting them)
WebP image name example for mybackground.png : mybackground.png.webp
Usage
- Download the script and make it executable
wget https://raw.githubusercontent.com/VirtuBox/wp-optimize/master/optimize.sh
chmod +x optimize.sh
- Launch the script and set the path of your images as first argument
./optimize.sh /path/to/your/images
To avoid permissions issues, you can run the script with another user with sudo
sudo -u www-data ./optimize.sh /path/to/your/images
Warning
Conversion process can take a while, you can use tmux
to launch the script and be able to close your ssh connection without interrupting conversion. Then just use tmux attach
to login back in your tmux session.