A tool for optimal WebP image compression
Project description
tool-webp-converter
A Python tool for optimal WebP image compression that automatically chooses between lossless and lossy compression to achieve the smallest file size.
Why WebP?
WebP is a modern image format developed by Google that provides superior compression for images on the web. It offers:
- Better compression: 25-35% smaller file sizes compared to JPEG and PNG
- Lossless and lossy compression: Choose the best compression method for your needs
- Transparency support: Like PNG, but with better compression
- Animation support: Similar to GIF but with much smaller file sizes
- Wide browser support: Supported by all modern browsers
Installation
Install the package from PyPI:
pip install tool-webp-converter
Usage
The tool provides a command-line interface for converting images to WebP format. It automatically tests both lossless and lossy compression and saves the smaller file.
Basic Usage
Convert a single image:
webp-converter image.jpg
Convert all images in a directory:
webp-converter /path/to/images/
Command Line Options
webp-converter [OPTIONS] INPUT_PATH
Arguments:
INPUT_PATH: Path to the input image file or directory
Options:
-o, --output-dir PATH: Output directory (defaults to input file directory)-q, --quality INTEGER: Quality for lossy compression (1-100, default: 80)-v, --verbose: Enable verbose logging-r, --recursive: Process directories recursively
Examples
Convert a single image with custom quality:
webp-converter photo.jpg --quality 90
Convert all images in a directory to a specific output folder:
webp-converter /path/to/images/ --output-dir /path/to/output/
Process a directory recursively (including subdirectories):
webp-converter /path/to/images/ --recursive
Supported Formats
The tool supports the following input formats:
- JPEG (.jpg, .jpeg)
- PNG (.png)
- BMP (.bmp)
- TIFF (.tiff, .tif)
- GIF (.gif)
- WebP (.webp)
How It Works
- Dual Compression: The tool creates both lossless and lossy WebP versions
- Automatic Selection: It automatically saves the smaller file
- Quality Control: You can adjust the quality for lossy compression (1-100)
- Batch Processing: Process single files or entire directories
- Recursive Support: Optionally process subdirectories
Output
The tool provides detailed feedback including:
- Compression statistics (original vs compressed size)
- Percentage reduction achieved
- Total space saved for batch operations
- Error reporting for failed conversions
Development
This project uses Poetry for dependency management. To set up the development environment:
# Install dependencies
poetry install
# Activate virtual environment
poetry shell
# Run the tool
python -m tool_webp_converter.cli image.jpg
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 tool_webp_converter-0.2.0.tar.gz.
File metadata
- Download URL: tool_webp_converter-0.2.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98dadaadd03b0c2fda4e440b77eca16ac8213b45e42f1faea3a3013601f2fa49
|
|
| MD5 |
bd7889290a6fea9b5ca8ade4af930933
|
|
| BLAKE2b-256 |
bef3bf1ac00ce48ab77b324dfdb3443af336cc6a62726f723282042e27109b60
|
File details
Details for the file tool_webp_converter-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tool_webp_converter-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ef9bd20980b6a805875c407d1435b286284d24c2928000fbe0693f31d379569
|
|
| MD5 |
83b86cf2d4b700527a6e4a6c34b7cad7
|
|
| BLAKE2b-256 |
9b9c2f563e3ad91ecc54d00933e89a660d61990b7afc2eda70c510276220bec6
|