A powerful command-line tool for converting images to WebP format
Project description
WebP Converter
A powerful command-line tool for converting images to WebP format with ease! Convert single images or batch process multiple files with customizable quality settings.
Features
- 🖼️ Multiple Format Support: Convert PNG, JPEG, and MPO images to WebP
- 🔧 Quality Control: Adjustable quality settings for lossy compression (1-100)
- 📁 Batch Processing: Convert multiple files, directories, or glob patterns
- 🔄 Smart Conversion: PNG files are converted losslessly, others use quality settings
- 💪 Error Handling: Robust error handling with continue-on-error options
- 🎯 Easy to Use: Simple CLI interface with helpful commands
Installation
Option 1: Install via pip (Recommended)
pip install webp-converter-cli
Option 2: Install via pipx (Isolated Environment)
# Install pipx if you don't have it
brew install pipx
pipx ensurepath
# Install webp-converter-cli
pipx install webp-converter-cli
Option 3: Install via Homebrew (Coming Soon)
# Add the tap
brew tap andriawan24/webp-converter
# Install the tool
brew install webp-convert
Option 4: Install from Source
- Clone the repository:
git clone https://github.com/andriawan24/webp-converter.git
cd webp-converter
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Usage
Convert a Single Image
Convert a single image file to WebP format:
# If installed via pip/pipx/homebrew
webp-convert convert -s input.jpg -o ./output -q 85
# If running from source
python main.py convert -s input.jpg -o ./output -q 85
Parameters:
-s, --source: Path to the source image file-o, --output-dir: Directory where the converted WebP file will be saved-q, --quality: Quality level for lossy compression (1-100, default: 80)
Batch Convert Multiple Images
Convert multiple images at once:
# Convert specific files
webp-convert convert-batch -s photo1.jpg -s photo2.png -o ./output
# Convert all images in a directory (recursive)
webp-convert convert-batch -s ./photos -o ./webp_output -q 90
# Use glob patterns
webp-convert convert-batch -s "*.jpg" -s "**/*.png" -o ./converted
# If running from source, use: python main.py convert-batch ...
Parameters:
-s, --source: Source files, directories, or glob patterns (can be specified multiple times)-o, --output-dir: Directory where converted WebP files will be saved-q, --quality: Quality level for lossy compression (1-100, default: 80)--continue-on-error/--stop-on-error: Continue processing if one file fails (default: continue)
Get Version Information
webp-convert --version
# If running from source: python main.py --version
Supported Formats
- PNG → WebP (lossless conversion)
- JPEG → WebP (lossy conversion with quality setting)
- MPO → WebP (lossy conversion with quality setting)
Examples
Basic Usage
# Convert a single JPEG with default quality (80)
python main.py convert -s vacation.jpg -o ./webp_images
# Convert with high quality
python main.py convert -s portrait.jpg -o ./output -q 95
# Convert a PNG (automatically lossless)
python main.py convert -s logo.png -o ./assets
Batch Processing
# Convert all JPEGs in current directory
python main.py convert-batch -s "*.jpg" -o ./converted
# Convert all images from multiple directories
python main.py convert-batch -s ./photos -s ./screenshots -o ./all_webp
# Process with custom quality and error handling
python main.py convert-batch -s ./images -o ./output -q 90 --stop-on-error
Output
The tool provides clear feedback during conversion:
✅ Successfully converted 'vacation.jpg' to WebP
📁 Output saved to: ./output/vacation.webp
🔍 Found 5 image file(s) to convert
[1/5] Converting photo1.jpg... ✅
[2/5] Converting photo2.png... ✅
[3/5] Converting photo3.jpg... ✅
[4/5] Converting photo4.png... ✅
[5/5] Converting photo5.jpg... ✅
📊 Conversion Summary:
✅ Successfully converted: 5 files
❌ Failed conversions: 0 files
📁 Output directory: ./output
Error Handling
The tool includes comprehensive error handling for:
- File not found errors
- Invalid file formats
- Permission issues
- Invalid quality parameters
- Output directory problems
Requirements
- Python 3.6+
- Pillow (PIL) for image processing
- Typer for CLI interface
Development
To set up for development:
- Clone the repository
- Create a virtual environment
- Install dependencies:
pip install -r requirements.txt - Run tests (if available)
License
This project is open source and available under the MIT License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
Made with 🤍 by Fawwaz
Version
Current version: 0.0.1
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file webp_converter_cli-0.0.1.tar.gz.
File metadata
- Download URL: webp_converter_cli-0.0.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03083ce8ff611e512d70f8f316d8419b49f2d3f5eddc2f0064fcbbb030bd92d8
|
|
| MD5 |
a5b2c17569e885aa21991b0f479cfc13
|
|
| BLAKE2b-256 |
8f9bfc9473e21d2d48e384ef4523242d893c4f372a5a026c753e417cbd6da3a9
|
File details
Details for the file webp_converter_cli-0.0.1-py3-none-any.whl.
File metadata
- Download URL: webp_converter_cli-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ed341c313fad7338595d32572e6475f08ee70b0b07d384cb7e571d15a649dd5
|
|
| MD5 |
167ac794a5ab43088a10c445413166ff
|
|
| BLAKE2b-256 |
f739629bfe2aa83771bff4441830a3f5fa3468bfc8465a1016095eccef8d130c
|