English| 中文
A simple and easy-to-use image to WebP converter tool that supports both command-line and Web UI interfaces.
- 🖼️ Batch convert JPG/JPEG/PNG images to WebP format
- 📦 Recursive directory scanning support
- 🎨 Customizable quality parameter (0-100)
- 🌐 Web UI interface with drag-and-drop upload
- 💾 Option to overwrite existing WebP files
- 🗑️ Option to delete original images after conversion
- 📊 Display conversion statistics and file size optimization
# Clone the repository
git clone <repository-url>
cd imgtowebp
# Install dependencies
pip install -r requirements.txt
# Install package (optional, enables command-line tools)
pip install .Ensure dependencies are installed:
pip install Pillow Flask werkzeug# Convert all images in current directory
python main.py
# Convert images in specified directory
python main.py --dir ./images
# Set quality parameter (0-100, default: 80)
python main.py --dir ./images --quality 90
# Scan only current directory, no subdirectories
python main.py --dir ./images --no-recursive
# Overwrite existing WebP files
python main.py --dir ./images --overwrite
# Delete original images after conversion
python main.py --dir ./images --replaceIf installed via pip install ., you can use directly:
imgtowebp --dir ./images --quality 85# Use default configuration (127.0.0.1:5000)
python main.py web
# Specify port
python main.py web --port 8080
# Specify output directory
python main.py web --output-dir ./webp_output
# Specify host and port
python main.py web --host 0.0.0.0 --port 5000python src/imgtowebp/web/app.py --port 5000imgtowebp-web --port 5000- Drag-and-drop or click to upload multiple image files
- Set quality parameter (0-100)
- Specify output subdirectory
- Option to overwrite existing files
- Display conversion results and statistics
Visit http://localhost:5000 to use the Web UI.
--dir DIR: Target directory (default: current directory)--quality QUALITY: WebP quality 0-100 (default: 80)--no-recursive: Do not scan subdirectories recursively--overwrite: Overwrite existing WebP files--replace: Delete original image files after conversion
--host HOST: Server host address (default: 127.0.0.1)--port PORT: Server port (default: 5000)--output-dir OUTPUT_DIR: Output directory (default: webp_output)
imgtowebp/
├── src/
│ └── imgtowebp/
│ ├── __init__.py
│ ├── core.py # Core conversion logic
│ ├── cli.py # Command-line tool
│ └── web/ # Web UI
│ ├── app.py # Flask application
│ ├── static/ # Static resources
│ └── templates/ # HTML templates
├── docs/
│ └── assets/
│ └── screenshots/ # Project screenshots
├── main.py # Unified entry point
├── pyproject.toml # Project configuration
├── requirements.txt # Dependencies list
└── README.md # Documentation
- Python >= 3.8
- Pillow >= 9.0.0
- Flask >= 2.0.0
- werkzeug >= 2.0.0
python main.py --dir ./photos --quality 85 --replacepython main.py web --host 0.0.0.0 --port 8080Converted: photo1.jpg -> photo1.webp
Converted: photo2.png -> photo2.webp
Deleted original: photo1.jpg
Summary:
Scanned files: 10
Eligible images: 2
Converted: 2
Skipped (existing webp): 0
Deleted originals: 2
Failed: 0
Total size before (converted): 5.23 MB
Total size after (webp): 3.45 MB
Saved: 1.78 MB (34.05%)
Issues and Pull Requests are welcome!

