Skip to main content

A high-performance CLI tool with directory watching to batch optimize images into WebP format.

Project description

imgopt-cli

PyPI version License: MIT Python Versions

The Intelligent WebP Converter for Modern Web Development.

imgopt is a high-performance, accessibility-first CLI tool designed to batch convert and optimize images (PNG, JPG, TIFF) into the efficient WebP format. It utilizes concurrency to process thousands of images in seconds and features a smart resizing engine that preserves aspect ratios.

Features ✨

  • ⚡ Fast: Uses multi-core processing (ProcessPoolExecutor) to utilize 100% of your CPU power.
  • 🧠 Smart: Auto-resizes images to a standard web width (default 1920px) without distortion. Prevents quality loss by retaining the original file if the WebP conversion results in a larger file size.
  • 👀 Watcher Mode: Automatically monitors a directory and processes new images on the fly.
  • 🤖 Auto-Configuration: Remembers your preferences using a hidden .imgoptrc file in your home directory, eliminating the need to repeatedly type CLI flags.
  • 🔍 Recursive: Automatically scans all subfolders and replicates the structure in the output.
  • 🛡️ Safe: Never overwrites your original files. Creates a separate folder for optimized images. Includes a --dry-run mode to safely simulate processing.
  • ♿ Accessible: Optimized for screen readers (NVDA/JAWS) using clean, sequential logging and optional audio cues upon completion.
  • 🧙‍♂️ Wizard Mode: Don't like memorizing commands? Run imgopt without arguments to enter an interactive, step-by-step wizard.

Installation 📦

You can install imgopt easily using pip or uv:

Option 1: Using pip (Standard)

pip install imgopt-cli

Option 2: Using uv (Recommended for speed)

uv tool install imgopt-cli

Note: The package name is imgopt-cli, but the command you run is simply imgopt.

Usage 🛠️

  • Interactive Wizard (Recommended for beginners): Just run the command without arguments. The tool will guide you step-by-step and save your preferences. imgopt

  • Quick CLI Mode (For Pros): Optimize a folder immediately using your saved config or default settings. imgopt ./photos

  • Watch Mode: Keep the script running to instantly optimize any new images dropped into the directory. imgopt ./assets --watch

  • Dry Run Simulation: Test the optimization logic without writing any files to disk. imgopt ./photos --dry-run

  • No Resizing: Keep original image dimensions. imgopt ./photos -w 0

  • Custom Overrides: Override the default quality and output folder. imgopt ./raw_images --output ./web_ready --quality 90

  • Silent Mode: Suppress detailed logs, perfect for automated scripts. imgopt ./assets --quiet --no-sound

Options ⚙️

  • -i, --interactive: Force the interactive wizard mode.
  • -q, --quality: Set WebP quality (0-100). Default is 80 or your .imgoptrc setting.
  • -w, --width: Max width in pixels. Use 0 to keep original dimensions. Default is 1920 or your .imgoptrc setting.
  • -o, --output: Custom name for the output folder. Default is optimized_webp or your .imgoptrc setting.
  • --watch: Watch the directory for new images and process them in the background.
  • --dry-run: Simulate the optimization process without saving any files.
  • --quiet: Suppress per-file logs (shows only the final summary).
  • --no-sound: Disable the "beep" notification sound at the end.
  • --version: Show the current tool version.
  • -h, --help: Display the detailed help menu.

Requirements

  • Python 3.8+
  • Pillow (Installed automatically)
  • Watchdog (Installed automatically)

License

This project is licensed under the MIT License. See LICENSE for details.

Support 💖

If you find this tool useful, please consider giving it a ⭐ on GitHub!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imgopt_cli-1.1.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imgopt_cli-1.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file imgopt_cli-1.1.0.tar.gz.

File metadata

  • Download URL: imgopt_cli-1.1.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for imgopt_cli-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b08fa24ff204942cefca661dc034d35c31da60d6ea1b3c15b478381f789fc15d
MD5 2925bfcfb1bc42968738cbe27da2e770
BLAKE2b-256 860e245a7eb3d0c7269451cf8c33f47cfaecec43321355cf07edd1fb0f0ef402

See more details on using hashes here.

File details

Details for the file imgopt_cli-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: imgopt_cli-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for imgopt_cli-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2797f1faee110e3b7935d3defaf4a2c5165a51cecf551e48465d87a1a937a306
MD5 69575f6e9b661f08d45ba24cd16d794f
BLAKE2b-256 2357a1eb239f8e3d71b891da2d1796a0967d794d6a2338d16646b5790c7c5a52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page