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.
- 🖼️ Converts multiple image formats to WebP
- 📁 Process entire directories or current directory
- ⚙️ Flexible
cwebp
options 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
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
- 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
~/.zshrc
file:
plugins=(... zsh-cwebpb)
- Restart your terminal or run:
source ~/.zshrc
Add this line to your ~/.zshrc
:
antigen bundle adi-li/zsh-cwebpb
Add this line to your ~/.zshrc
:
zinit load "adi-li/zsh-cwebpb"
# 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
# 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
- JPEG/JPG
- PNG
- GIF
- BMP
- TIFF/TIF
All file extensions are matched case-insensitively (e.g., .JPG
, .png
, .GiF
all work).
🖼️ 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
cwebpb
- Batch WebP conversion function (cwebp batch)
MIT License - feel free to use and modify as needed.
- 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
If you encounter any problems or have suggestions, please open an issue on GitHub.