Image optimization bash script
Go to file
2018-10-29 18:52:28 +01:00
crons improve cronjobs 2018-08-07 15:27:37 +02:00
docs add screenshot 2018-08-10 06:32:50 +02:00
.gitignore add command arguments 2018-10-24 07:47:01 +02:00
img-optimize.png update screenshot 2018-08-10 06:35:13 +02:00
install-optipng.sh comment bash script 2018-07-30 14:36:29 +02:00
install-webp.sh comment bash script 2018-07-30 14:36:29 +02:00
LICENSE Initial commit 2016-10-16 18:27:04 +02:00
optimize.sh fix menu display 2018-10-29 18:52:28 +01:00
README.md add screenshot 2018-08-10 06:32:50 +02:00

Bash script to optimize your images and convert them in WebP

img-optimize

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

  1. optimize jpg images with jpegoptim
  2. optimize png images with optipng
  3. convert jpg & png images in WebP (without deleting them)

WebP image name example for mybackground.png : mybackground.png.webp


Usage

  1. Download the script and make it executable
wget https://raw.githubusercontent.com/VirtuBox/wp-optimize/master/optimize.sh
chmod +x optimize.sh
  1. 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.

Credits

WebP conversion script is inspired by this DigitalOcean Community Tutorial