Skip to content

pixopt

A powerful, easy-to-use Python library and CLI tool for optimizing images for web and storage.

![PyPI](https://img.shields.io/pypi/v/pixopt) ![Python](https://img.shields.io/pypi/pyversions/pixopt) ![CI](https://img.shields.io/github/actions/workflow/status/MathiasPaulenko/pixopt/bump-version.yml?label=CI) ![License](https://img.shields.io/github/license/MathiasPaulenko/pixopt)


What is pixopt?

pixopt is a fast Python image optimizer designed for modern web workflows. It provides both a rich command-line interface (CLI) and a clean Python API to resize, compress, convert formats, generate responsive assets, extract lazy-loading placeholders, and detect the optimal format automatically.

Whether you are a developer automating image pipelines, a designer preparing assets, or a DevOps engineer optimizing static sites, pixopt handles the heavy lifting so you don't have to.


Highlights

  • ๐Ÿ–ผ๏ธ Format conversion โ€” JPEG, PNG, WEBP, AVIF, GIF, HEIC/HEIF, SVG
  • ๐ŸŽž๏ธ Animated GIF โ†’ WEBP โ€” convert animated GIFs to much lighter animated WEBP
  • ๐Ÿงน SVG minification โ€” pure-Python SVG cleanup (no Node.js tools needed)
  • ๐Ÿ“ฑ HEIC/HEIF import โ€” open iPhone photos directly via pillow-heif
  • ๐ŸŽฏ Lossless mode โ€” lossless PNG/WEBP compression for UI assets
  • ๐Ÿ” Adaptive quality โ€” binary-search quality to hit a target file size
  • ๐Ÿ“Š Visual comparison โ€” interactive HTML before/after slider
  • ๐Ÿ“ Responsive srcset โ€” generate multiple width variants + HTML snippets
  • ๐ŸŽจ Lazy-loading placeholders โ€” dominant color, LQIP data URI, blurhash
  • ๐Ÿง  Smart format detection โ€” auto-select WEBP/JPEG/PNG based on content
  • ๐Ÿ’พ Backup originals โ€” copy originals before processing
  • โšก Batch processing โ€” single files, directories, or multiple files at once
  • ๐Ÿ’ป Beautiful CLI โ€” built with Typer for an intuitive experience

Quick Start

Install and run in one line:

pip install pixopt
pixopt optimize photo.jpg --quality 80 --width 1200
from pixopt import optimize_image
from pixopt.models import OutputFormat

result = optimize_image(
    "photo.jpg",
    "photo_optimized.webp",
    max_width=1200,
    quality=80,
    output_format=OutputFormat.WEBP,
)
print(f"Saved {result.savings_percent:.1f}%")

Next Steps


License

MIT License โ€” see LICENSE for details.