cwebpb - Batch WebP Converter Plugin for Oh-My-Zsh
July 22, 2025 ยท View on GitHub
A convenient Oh-My-Zsh plugin that converts common image formats (JPG, PNG, GIF, BMP, TIFF) to WebP format using Google's cwebp tool in batch mode.
Features
- ๐ผ๏ธ Converts multiple image formats to WebP
- ๐ Process entire directories or current directory
- โ๏ธ Flexible
cwebpoptions support - ๐ Safe: skips existing WebP files to avoid overwriting
- ๐ Progress reporting with conversion summary
- ๐ฏ Case-insensitive file extension matching
- โจ Clean, colorful output with status indicators
Prerequisites
You need to have cwebp installed on your system:
macOS:
brew install webp
Ubuntu/Debian:
sudo apt install webp
Arch Linux:
sudo pacman -S libwebp
Windows (WSL):
sudo apt install webp
Installation
Method 1: Using Oh-My-Zsh custom plugins
- Clone this repository into your custom plugins directory:
git clone https://github.com/adi-li/zsh-cwebpb.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-cwebpb
- Add the plugin to your
~/.zshrcfile:
plugins=(... zsh-cwebpb)
- Restart your terminal or run:
source ~/.zshrc
Method 2: Using Antigen
Add this line to your ~/.zshrc:
antigen bundle adi-li/zsh-cwebpb
Method 3: Using Zinit
Add this line to your ~/.zshrc:
zinit load "adi-li/zsh-cwebpb"
Usage
Basic Usage
# Convert all images in current directory (default quality: 85)
cwebpb
# Convert images in specific directory
cwebpb /path/to/images
# Convert with custom quality
cwebpb -- -q 90
# Convert specific directory with custom quality
cwebpb /path/to/images -- -q 90
Advanced Usage
# High quality conversion
cwebpb -- -q 95 -m 6
# Lossless conversion
cwebpb -- -lossless
# Low quality for smaller files
cwebpb -- -q 60
# Multiple options
cwebpb /path/to/images -- -q 80 -alpha_q 85 -m 4
Supported Image Formats
- JPEG/JPG
- PNG
- GIF
- BMP
- TIFF/TIF
All file extensions are matched case-insensitively (e.g., .JPG, .png, .GiF all work).
Output Example
๐ผ๏ธ Converting images in: ./photos
โ๏ธ Using cwebp options: -q 85
โ Converted: IMG_001.jpg โ IMG_001.webp
โ Converted: photo.PNG โ photo.webp
โ Skipped (already exists): existing.webp
โ Failed to convert: corrupted.gif
๐ Summary: 2 converted, 1 skipped, 1 failed
Commands
cwebpb- Batch WebP conversion function (cwebp batch)
License
MIT License - feel free to use and modify as needed.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Issues
If you encounter any problems or have suggestions, please open an issue on GitHub.