toWebP is a simple Bash script that converts images of specific types (JPEG, JPG, and PNG) to WebP format, compresses them with a default value of 90
, and deletes the original files. The script can be run locally or installed globally on Linux, macOS, and other Unix-like systems.
Note: As described, this script will remove the original image files after converting them to WebP format. Ensure you have backups before running this script.
Want to get started quickly? Here's a quick rundown for your command-line interface (CLI):
- Clone the repository:
git clone https://github.com/averrois/towebp.sh.git
- Navigate into the cloned repository:
cd towebp.sh
- Make the script executable:
chmod +x towebp.sh
- Run the script:
./towebp.sh
This will convert all JPEG, JPG, and PNG images in the current directory to WebP format with a default compression quality of 90.
To install towebp.sh
, clone the repository using Git:
git clone https://github.com/averrois/towebp.sh.git
Then, navigate into the cloned repository:
cd towebp.sh
Make the script executable:
chmod +x towebp.sh
If you don't have Git installed, you can download a ZIP archive of the repository from GitHub:
- Extract the ZIP archive and navigate into the extracted directory
To run the script locally, simply make the script executable: chmod +x towebp.sh
To install towebp.sh
globally, move the script to a directory in your system's PATH (e.g., /usr/local/bin
):
sudo mv towebp.sh /usr/local/bin
Run the script in the directory containing the images you want to convert:
./towebp.sh
This will convert all JPEG, JPG, and PNG images in the current directory to WebP format with a default compression quality of 90
.
To specify a custom compression quality, pass the quality value as an argument:
./towebp.sh 80
This will convert the images with a compression quality of 80
.
To display the help message, run the script with the -h
or --help
argument:
./towebp.sh -h
This will display the usage message:
USAGE: towebp.sh <quality>
The script requires the cwebp
command-line tool to be installed. If it's not installed, the script will provide instructions on how to install it based on your operating system. More information is available on developers.google.com.
The script is compatible with the following operating systems:
- Linux (e.g., Arch, Ubuntu, Debian)
- macOS (via Homebrew)
- FreeBSD
- Windows (via MSYS or Cygwin)
toWebP is licensed under the MIT License.