Convert JPG and PNG images in a folder to WebP format with selective options.
Project description
webpall
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.
Features
- 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.
Installation
webpall is available on PyPI and can be installed using pip:
pip install webpall
Requirements
- Python 3.6 or later.
- Pillow library for image processing (automatically installed with
webpall).
Usage
After installing, you can use webpall from the command line to quickly convert images in a specified folder.
Default Behavior
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:
webpall
Basic Command Structure
webpall --dir <directory_path> [options]
Command-Line 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 |
Examples
Here are some common usage examples to help you get started:
Example 1: Convert All Images in the Current Directory to WebP
webpall
This converts all JPG and PNG files in the current directory to WebP format, keeping the original files and using the default quality of 90%.
Example 2: Convert All Images in a Specific Directory with Custom Quality
webpall --dir /path/to/images --quality 80
This command converts all JPG and PNG images in /path/to/images to WebP with a quality setting of 80.
Example 3: Convert Only JPG Images and Delete the Original Files
webpall --dir /path/to/images --type jpg --delete
This will convert only JPG files to WebP in /path/to/images, deleting the original JPG files after conversion.
Example 4: Convert All Images in Subdirectories with Lossless Quality
webpall --dir /path/to/images --subdirs --quality 100
This 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.
Example Output
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
License
This project is licensed under the MIT License. See the LICENSE file for more details.
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 webpall-0.1.2.tar.gz.
File metadata
- Download URL: webpall-0.1.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d21eba53e71de0b4f509eff02ee9b6abdc0b0c7c5305b5c682b05fdef7d5d0fc
|
|
| MD5 |
9ff1b4ae5c64176df3caa8cbd6621b95
|
|
| BLAKE2b-256 |
e6083b84bb9609cea60520a9857d859e013e8c1094394c0968048402ef8d9a81
|
File details
Details for the file webpall-0.1.2-py3-none-any.whl.
File metadata
- Download URL: webpall-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5724bfab0ac4d5a17d58a5954cb629287dc3ede81b8f48d6bed27eb033f2d57
|
|
| MD5 |
a0f24bce3dc865e4358418f0ecd6693f
|
|
| BLAKE2b-256 |
099aed3019f47b577b9aa5b729c38fbf36efbb41173f093e0a6df0120dfe194e
|