update README informations

This commit is contained in:
VirtuBox 2018-10-29 19:11:04 +01:00
parent ed60d3dc14
commit c00a163cc6
3 changed files with 131 additions and 120 deletions

124
README.md
View File

@ -1,60 +1,66 @@
## Bash script to optimize your images and convert them in WebP ## Bash script to optimize your images and convert them in WebP
![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png) ![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png)
### Prerequisite ### Prerequisite
* jpegoptim * jpegoptim
* optipng * optipng
* WebP * WebP
Debian/Ubuntu : Debian/Ubuntu :
```bash ```bash
sudo apt install jpegoptim optipng webp -y sudo apt install jpegoptim optipng webp -y
``` ```
Centos 7 : Centos 7 :
```bash ```bash
sudo yum install optipng jpegoptim libwebp-tools -y sudo yum install optipng jpegoptim libwebp-tools -y
``` ```
### What does the script do ---
1) optimize jpg images with jpegoptim ### Installation
2) optimize png images with optipng
3) convert jpg & png images in WebP (without deleting them) 1) Download the script and make it executable
WebP image name example for mybackground.png : mybackground.png.webp ```bash
wget -O $HOME/optimize.sh https://raw.githubusercontent.com/VirtuBox/wp-optimize/master/optimize.sh
--- chmod +x $HOME/optimize.sh
```
### Usage
2) Add an alias in your bashrc
1) Download the script and make it executable
```bash
```bash echo "alias img-optimize=$HOME/optimize.sh" >> $HOME/.bashrc
wget https://raw.githubusercontent.com/VirtuBox/wp-optimize/master/optimize.sh source $HOME/.bashrc
chmod +x optimize.sh ```
```
2) Launch the script and set the path of your images as first argument ### Usage
```bash ```bash
./optimize.sh /path/to/your/images Usage: img-optimize [options] <image path>
``` Options:
--jpg <image path> ..... optimize all jpg images
To avoid permissions issues, you can run the script with another user with sudo --png <image path> ..... optimize all png images
--webp <image path> ..... convert all images in webp
```bash --nowebp <image path> ..... optimize all png & jpg images
sudo -u www-data ./optimize.sh /path/to/your/images --all <image path> ..... optimize all images (png + jpg + webp)
``` Other options :
-h, --help, help ... displays this help information
### Warning Examples:
optimize all jpg images in /var/www/images
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. img-optimize --jpg /var/www/images
### Credits ```
### 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](https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website) WebP conversion script is inspired by this [DigitalOcean Community Tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website)

View File

@ -1,60 +1,66 @@
## Bash script to optimize your images and convert them in WebP ## Bash script to optimize your images and convert them in WebP
![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png) ![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png)
### Prerequisite ### Prerequisite
* jpegoptim * jpegoptim
* optipng * optipng
* WebP * WebP
Debian/Ubuntu : Debian/Ubuntu :
```bash ```bash
sudo apt install jpegoptim optipng webp -y sudo apt install jpegoptim optipng webp -y
``` ```
Centos 7 : Centos 7 :
```bash ```bash
sudo yum install optipng jpegoptim libwebp-tools -y sudo yum install optipng jpegoptim libwebp-tools -y
``` ```
### What does the script do ---
1) optimize jpg images with jpegoptim ### Installation
2) optimize png images with optipng
3) convert jpg & png images in WebP (without deleting them) 1) Download the script and make it executable
WebP image name example for mybackground.png : mybackground.png.webp ```bash
wget -O $HOME/optimize.sh https://raw.githubusercontent.com/VirtuBox/wp-optimize/master/optimize.sh
--- chmod +x $HOME/optimize.sh
```
### Usage
2) Add an alias in your bashrc
1) Download the script and make it executable
```bash
```bash echo "alias img-optimize=$HOME/optimize.sh" >> $HOME/.bashrc
wget https://raw.githubusercontent.com/VirtuBox/wp-optimize/master/optimize.sh source $HOME/.bashrc
chmod +x optimize.sh ```
```
2) Launch the script and set the path of your images as first argument ### Usage
```bash ```bash
./optimize.sh /path/to/your/images Usage: img-optimize [options] <image path>
``` Options:
--jpg <image path> ..... optimize all jpg images
To avoid permissions issues, you can run the script with another user with sudo --png <image path> ..... optimize all png images
--webp <image path> ..... convert all images in webp
```bash --nowebp <image path> ..... optimize all png & jpg images
sudo -u www-data ./optimize.sh /path/to/your/images --all <image path> ..... optimize all images (png + jpg + webp)
``` Other options :
-h, --help, help ... displays this help information
### Warning Examples:
optimize all jpg images in /var/www/images
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. img-optimize --jpg /var/www/images
### Credits ```
### 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](https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website) WebP conversion script is inspired by this [DigitalOcean Community Tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website)

View File

@ -16,8 +16,7 @@ _help() {
echo " Other options :" echo " Other options :"
echo " -h, --help, help ... displays this help information" echo " -h, --help, help ... displays this help information"
echo "Examples:" echo "Examples:"
echo "" echo " optimize all jpg images in /var/www/images"
echo "optimize all jpg images in /var/www/images"
echo " img-optimize --jpg /var/www/images" echo " img-optimize --jpg /var/www/images"
echo "" echo ""
return 0 return 0