Skip to content

Commit

Permalink
release v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtuBox committed Apr 5, 2019
1 parent af9f345 commit ae9dc38
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 114 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Changed

## [V1.1] - 2019-04-05

### Added

- Interactive mode with `img-optimize -i`
- check if optipng, jpegoptim or cwebp executable before optimization
- additional install method

### Fixed

- images path replaced by current directory if empty

## [v1.0] - 2019-03-20

- Initial release
59 changes: 40 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,90 @@
## Bash script to optimize your images and convert them in WebP
# Image optimization bash script

![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png)

### Prerequisite
![GitHub](https://img.shields.io/github/license/VirtuBox/img-optimize.svg) ![GitHub release](https://img.shields.io/github/release/VirtuBox/img-optimize.svg) ![GitHub last commit](https://img.shields.io/github/last-commit/VirtuBox/img-optimize.svg) ![Github stars](https://img.shields.io/github/stars/VirtuBox/img-optimize.svg)

* jpegoptim
* optipng
* WebP
## Prerequisite

- jpegoptim for jpg optimization
- optipng for png optimization
- cwebp for WebP conversion

Debian/Ubuntu :

```bash
sudo apt install jpegoptim optipng webp -y
```

Centos 7 :
Centos 7 :

```bash
sudo yum install optipng jpegoptim libwebp-tools -y
```

---
--------------------------------------------------------------------------------

### Installation
## Installation

1) Download the script
1) Clone the repository

```bash
git clone https://github.com/VirtuBox/img-optimize.git $HOME/.img-optimize
```

2) Add an alias in your bashrc
2) Install the script

**Method 1** : Add an alias in .bashrc

With this method img-optimize can only be used by the current user

```bash
echo "alias img-optimize=$HOME/.img-optimize/optimize.sh" >> $HOME/.bashrc
source $HOME/.bashrc
```

### Usage
**Method 2** : Copy the script in /usr/local/bin

With this method img-optimize can be used by all users

```bash
sudo cp $HOME/.img-optimize/optimize.sh /usr/local/bin/img-optimize
```

## Usage

```bash
Usage: img-optimize [options] <images path>
If images path is not defined, img-optimize will use the current directory
If images path is empty, img-optimize will use the current directory
Options:
--jpg <images path> ..... optimize all jpg images
--png <images path> ..... optimize all png images
--webp <images path> ..... convert all images in webp
--nowebp <images path> ..... optimize all png & jpg images
--all <images path> ..... optimize all images (png + jpg + webp)
-i, --interactive ... run img-optimize in interactive mode
Other options :
-h, --help, help ... displays this help information
Examples:
Example:
optimize all jpg images in /var/www/images
img-optimize --jpg /var/www/images
```

### Update the script
## Update the script

To update the script, just run :

```bash
git -C $HOME/.img-optimize pull
```

source .bashrc
If you previously used the 2nd install method, you have to copy the script again to update it

```bash
sudo cp $HOME/.img-optimize/optimize.sh /usr/local/bin/img-optimize -f
```

### Setup daily cronjob
## Setup daily cronjob

You copy the scripts to /etc/cron.daily :

Expand All @@ -79,10 +98,12 @@ chmod +x /etc/cron.daily/webp-cron

Then just edit your websites path set with the variables `sites` at the beginning of the cron scripts.

### Warning
## 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
## Credits

- WebP conversion script was 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 was inspired by this [DigitalOcean Community Tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website)
- Tutorial about webp conversion available on [jesuisadmin.fr](https://jesuisadmin.fr/convertir-vos-images-en-webp-nginx/) (in french)
71 changes: 46 additions & 25 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,90 @@
## Bash script to optimize your images and convert them in WebP
# Image optimization bash script

![img-optimize](https://raw.githubusercontent.com/VirtuBox/img-optimize/master/img-optimize.png)

### Prerequisite
![GitHub](https://img.shields.io/github/license/VirtuBox/img-optimize.svg) ![GitHub release](https://img.shields.io/github/release/VirtuBox/img-optimize.svg) ![GitHub last commit](https://img.shields.io/github/last-commit/VirtuBox/img-optimize.svg) ![Github stars](https://img.shields.io/github/stars/VirtuBox/img-optimize.svg)

* jpegoptim
* optipng
* WebP
## Prerequisite

- jpegoptim for jpg optimization
- optipng for png optimization
- cwebp for WebP conversion

Debian/Ubuntu :

```bash
sudo apt install jpegoptim optipng webp -y
```

Centos 7 :
Centos 7 :

```bash
sudo yum install optipng jpegoptim libwebp-tools -y
```

---
--------------------------------------------------------------------------------

### Installation
## Installation

1) Download the script
1) Clone the repository

```bash
git clone https://github.com/VirtuBox/img-optimize.git $HOME/.img-optimize
```

2) Add an alias in your bashrc
2) Install the script

**Method 1** : Add an alias in .bashrc

With this method img-optimize can only be used by the current user

```bash
echo "alias img-optimize=$HOME/.img-optimize/optimize.sh" >> $HOME/.bashrc
source $HOME/.bashrc
```

### Usage
**Method 2** : Copy the script in /usr/local/bin

With this method img-optimize can be used by all users

```bash
Usage: img-optimize [options] <image path>
sudo cp $HOME/.img-optimize/optimize.sh /usr/local/bin/img-optimize
```

## Usage

```bash
Usage: img-optimize [options] <images path>
If images path is empty, img-optimize will use the current directory
Options:
--jpg <image path> ..... optimize all jpg images
--png <image path> ..... optimize all png images
--webp <image path> ..... convert all images in webp
--nowebp <image path> ..... optimize all png & jpg images
--all <image path> ..... optimize all images (png + jpg + webp)
--jpg <images path> ..... optimize all jpg images
--png <images path> ..... optimize all png images
--webp <images path> ..... convert all images in webp
--nowebp <images path> ..... optimize all png & jpg images
--all <images path> ..... optimize all images (png + jpg + webp)
-i, --interactive ... run img-optimize in interactive mode
Other options :
-h, --help, help ... displays this help information
Examples:
Example:
optimize all jpg images in /var/www/images
img-optimize --jpg /var/www/images

```

### Update the script
## Update the script

To update the script, just run :

```bash
git -C $HOME/.img-optimize pull
```

source .bashrc
If you previously used the 2nd install method, you have to copy the script again to update it

```bash
sudo cp $HOME/.img-optimize/optimize.sh /usr/local/bin/img-optimize -f
```

### Setup daily cronjob
## Setup daily cronjob

You copy the scripts to /etc/cron.daily :

Expand All @@ -79,10 +98,12 @@ chmod +x /etc/cron.daily/webp-cron

Then just edit your websites path set with the variables `sites` at the beginning of the cron scripts.

### Warning
## 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
## Credits

- WebP conversion script was 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 was inspired by this [DigitalOcean Community Tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website)
- Tutorial about webp conversion available on [jesuisadmin.fr](https://jesuisadmin.fr/convertir-vos-images-en-webp-nginx/) (in french)
Loading

0 comments on commit ae9dc38

Please sign in to comment.