Skip to main content

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

  1. Clone the repository:
git clone https://github.com/andriawan24/webp-converter.git
cd webp-converter
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. 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:

  1. Clone the repository
  2. Create a virtual environment
  3. Install dependencies: pip install -r requirements.txt
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webp_converter_cli-1.0.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webp_converter_cli-1.0.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file webp_converter_cli-1.0.0.tar.gz.

File metadata

  • Download URL: webp_converter_cli-1.0.0.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

Hashes for webp_converter_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1d1231673daecc32cc360c94b0a1a1f7283fc62a53deca50d2a969b48130a181
MD5 f4ae2f379f76628fa258abd0b5ac40a8
BLAKE2b-256 31016bb39aac5a602aac758c6e4c4ce6adae53f372ac8582d9565b5d68671941

See more details on using hashes here.

File details

Details for the file webp_converter_cli-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for webp_converter_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b26d8a17d8275f6f34a79e32233f6a5a9a5f6aea3041121591753dc78531f543
MD5 78ca75e4114c40d41d8e897babc1b763
BLAKE2b-256 b693b9af2900336cd85d5f4a58d7da159454a6543cb64a5fbf3556f507b53b1b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page