Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webpall

PyPI Downloads
PyPI Downloads

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.

About

Python CLI tool to convert JPG and PNG images to WebP format with customizable quality, folder processing, and optional original file deletion.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages