Metadata-Version: 2.4
Name: webp-tui
Version: 2.0.1
Summary: Batch image-to-WebP converter with an interactive terminal UI (TUI) and CLI for Windows
Author: RenX86
License: MIT License
        
        Copyright (c) 2024 RenX86
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/RenX86/WebP-Image-Converter
Project-URL: Repository, https://github.com/RenX86/WebP-Image-Converter
Project-URL: Issues, https://github.com/RenX86/WebP-Image-Converter/issues
Keywords: webp,image,converter,tui,textual,pillow,cli
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Pillow>=9.0.0
Requires-Dist: textual>=0.80.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# WebP Image Converter

A fast, safe batch image-to-WebP converter for Windows with an interactive **Terminal UI (TUI)** and a scriptable **CLI**, powered purely by Pillow (`libwebp`) — no external binaries required.

> Looking for v1.0 (Flask Web UI, `cwebp`/`ExifTool`, and Stable Diffusion metadata)? Check out the `v1.0.0` git tag.

## Features

- **Interactive Terminal UI (`webp-converter`)**: Browse folders, preview file counts and sizes, adjust settings, watch live per-file progress and space saved, or cancel mid-batch.
- **Scriptable CLI**: Pass a folder path and flags for automated/batch workflows with clean exit codes (`0` success, `1` partial failure/skip, `2` fatal error).
- **Pure Python / Pillow**: Converts JPG, JPEG, PNG, TIFF/TIF, BMP, and GIF (including **animated GIFs** to animated WebP) in-process — no `cwebp.exe` or `ExifTool` setup needed.
- **Lossy or pixel-exact lossless**: Configurable quality (`0–100`) and compression effort (`method 0–6`), or lossless encoding with exact RGB preservation under transparency.
- **Metadata preservation**: Carries over EXIF tags, ICC color profiles, XMP packets, and standard PNG/GIF/BMP text comments (`Author`, `Software`, `Comment`, `Creation Time`), and automatically applies EXIF orientation to static images.
- **Safe by default**:
  - Original files are kept unless `--delete-originals` (or the TUI toggle) is enabled.
  - Files are written atomically via temp files and originals are only removed after verified output.
  - Never overwrites silently: `photo.jpg` + `photo.png` become `photo_jpg.webp` + `photo_png.webp`, and existing `.webp` files are left alone unless `--overwrite` is set.

## Requirements

- Windows 10 / 11 (Windows Terminal recommended for the TUI)
- Python 3.9 or higher

## Installation

### Recommended: install globally from PyPI

Using `uv` or `pipx` (adds `webp-converter` to your `PATH` in an isolated environment):

```powershell
uv tool install webp-tui
# or
pipx install webp-tui
```

Or with `pip`:

```powershell
pip install webp-tui
```

After installation, `webp-converter` can be launched from any folder in PowerShell, Command Prompt, or Windows Terminal.

### Installing from local source (development)

```powershell
# Global editable install with uv:
uv tool install -e .

# Or inside a virtual environment:
pip install -e ".[dev]"
```

### Running without installing globally

```powershell
pip install -r requirements.txt
python WebP-Image-Converter.py
```

Or double-click / run `run-webp-converter.bat`.

## Usage

### Interactive Terminal UI (TUI — Default)

Run with no arguments, or pass a starting folder path:

```powershell
webp-converter
# or open directly on a folder:
webp-converter C:\Users\Name\Pictures\Batch
```

Keybindings inside the TUI:
- `Ctrl+R`: Start conversion
- `Ctrl+D`: Dry run (preview output filenames without modifying files)
- `Esc`: Cancel a running batch
- `Ctrl+Q`: Quit

### Command-Line Interface (CLI — Secondary)

Pass `--cli` along with a folder path and flags for headless/scripted runs:

```powershell
webp-converter --cli C:\Users\Name\Pictures\Batch [OPTIONS]
```

#### Options

- `--cli`: Run in headless command-line mode instead of opening the TUI
- `--tui`: Force the interactive terminal UI (default)
- `--quality, -q`: WebP quality `0–100` (default: `90`)
- `--lossless` / `--lossy`: Pixel-exact lossless encoding / force lossy
- `--method, -m`: WebP compression effort `0–6` (`0` fastest, `6` smallest; default: `4`)
- `--keep-originals`: Keep original files after conversion (default)
- `--delete-originals`: Delete original files after successful conversion
- `--overwrite`: Overwrite existing `.webp` files instead of choosing a new name
- `--recursive` / `--no-recursive`: Scan subfolders recursively (default) or top-level only
- `--workers, -w`: Number of worker threads (default: CPU count)
- `--dry-run`: Preview planned conversions without modifying any files
- `--formats`: Supported extensions (default: `.jpg .jpeg .png .tif .tiff .bmp .gif`)
- `--log-file`: Write detailed logs to a file
- `--verbose, -v`: Enable debug logging
- `--config`: Path to a JSON configuration file

#### Examples

```powershell
# Convert a folder at quality 85
webp-converter --cli D:\Photos --quality 85

# Lossless conversion, deleting originals only after success
webp-converter --cli D:\Screenshots --lossless --delete-originals

# Top-level folder only, dry run
webp-converter --cli D:\Uploads --no-recursive --dry-run

# Maximum compression effort with 8 worker threads
webp-converter --cli D:\Exports -q 80 -m 6 -w 8
```

## Configuration

Settings can be saved from the TUI (`Save Config`) or edited in `config.json` (or `%APPDATA%\webp-converter\config.json` when installed globally):

```json
{
    "webp_quality": 90,
    "lossless": false,
    "method": 4,
    "delete_originals": false,
    "overwrite": false,
    "recursive": true,
    "supported_formats": [".jpg", ".jpeg", ".png", ".tif", ".tiff", ".bmp", ".gif"],
    "max_workers": 8
}
```

Command-line flags always override `config.json`.

## Running the tests

```powershell
pip install -r requirements-dev.txt
python -m pytest
```
