webpall is a Python-based command-line tool designed to convert images in JPG and PNG formats to WebP format. It offers flexible options for quality settings, including or excluding subdirectories, and managing original files post-conversion. With WebP format, you can achieve smaller file sizes without significant loss in quality, making it an excellent choice for web optimization and storage management.
- Selective File Type Conversion: Choose to convert only JPGs, only PNGs, or both file types.
- Quality Control: Adjust the WebP conversion quality from 1-100 (with 100 offering lossless compression).
- Delete Originals Option: Optionally delete original images after conversion to WebP format.
- Recursive Processing: Include subdirectories in the conversion process to handle large, nested image folders.
webpall is available on PyPI and can be installed using pip:
pip install webpall- Python 3.6 or later.
- Pillow library for image processing (automatically installed with
webpall).
After installing, you can use webpall from the command line to quickly convert images in a specified folder.
If you run webpall without any options, it will:
- Convert all JPG and PNG images in the current directory to WebP format.
- Keep the original image files intact (i.e., they will not be deleted).
- Set the WebP conversion quality to 90%, providing high-quality compressed images.
To use this default behavior, run:
webpallwebpall --dir <directory_path> [options]| Option | Description | Default |
|---|---|---|
--dir <directory> |
Path to the folder containing images. | Current folder (.) |
--delete |
Deletes the original files after conversion. | Disabled |
--type <all|jpg|png> |
Specifies the type of images to convert: jpg, png, or all. |
all |
--quality <1-100> |
Sets the quality of the WebP conversion (100 is lossless). | 90 |
--subdirs or -s |
Includes subdirectories in the conversion process. | Disabled |
Here are some common usage examples to help you get started:
webpallThis converts all JPG and PNG files in the current directory to WebP format, keeping the original files and using the default quality of 90%.
webpall --dir /path/to/images --quality 80This command converts all JPG and PNG images in /path/to/images to WebP with a quality setting of 80.
webpall --dir /path/to/images --type jpg --deleteThis will convert only JPG files to WebP in /path/to/images, deleting the original JPG files after conversion.
webpall --dir /path/to/images --subdirs --quality 100This command will convert all JPG and PNG images within /path/to/images and its subdirectories to WebP with lossless quality (100), retaining the original images.
During the conversion process, webpall will display status messages for each file:
Starting conversion process...
Found 5 image files to convert.
Converted /path/to/image1.jpg to /path/to/image1.webp
Converted /path/to/image2.png to /path/to/image2.webp and deleted /path/to/image2.png
This project is licensed under the MIT License. See the LICENSE file for more details.