Skip to main content

High-quality image compression like TinyPNG and Squoosh

Project description

pysqueeze

pysqueeze is a high-quality image compression library for Python, inspired by tools like TinyPNG and Squoosh. It focuses on achieving significant file size reduction while preserving perceptual image quality.

The library is designed for developers who need reliable, automated image optimization for web, mobile, and backend pipelines.

Key Features

  • Convert JPG and PNG images to WebP or AVIF
  • Perceptual compression with sensible defaults
  • Target file size compression (TinyPNG-like behavior)
  • Automatic format selection (WebP vs AVIF)
  • Metadata stripping for smaller output files
  • Simple Python API and command-line interface
  • Cross-platform support (Windows, macOS, Linux)

Install

pip install pysqueeze

Standard compression (default)

from pysqueeze import compress
compress("input.jpg", "output.webp")

Target file size compression

from pysqueeze import compress
compress(
    "input.jpg",
    "output.webp",
    mode="target",
    target_kb=200,
)

Automatic format selection (best result)

from pysqueeze import compress
compress(
    "input.jpg",
    "output",
    mode="auto",
)

Standard compression

pysqueeze input.jpg -o output.webp

Target file size (TinyPNG-style)

pysqueeze input.jpg -o output.webp --mode target --target-kb 200

Automatic format selection

pysqueeze input.jpg -o output --mode auto

Options

Option Description
--mode standard, target, or auto
--max-size Maximum width/height in pixels (default: 1600)
--format Output format (webp or avif, ignored in auto mode)
--quality Compression quality override
--target-kb Target file size in KB (required for target mode)

LICENSE

MIT License

Project Status

pysqueeze is actively developed and suitable for production use. Contributions, issues, and feature requests are welcome.

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

pysqueeze-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

pysqueeze-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file pysqueeze-0.1.1.tar.gz.

File metadata

  • Download URL: pysqueeze-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysqueeze-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5780a730791000413ddfdf7ba54f992b5f0da8920521fef7f243ea2b634b3cd8
MD5 74cbf112bce2103c0a1b8b45e385e398
BLAKE2b-256 2f1e4bcca749fb9aa1e2c597a648194d6e215d1a31c1f69013fb0ba55350604c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysqueeze-0.1.1.tar.gz:

Publisher: publish.yml on Gerard-007/pysqueeze

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pysqueeze-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pysqueeze-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysqueeze-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 db4d2a1c911adb153db449dcb7de3bad0e8edd2c323dfb98afd69296cc88ea2f
MD5 e8668a9d4d1d68b5a79fe5d7b8bdac29
BLAKE2b-256 dbc1fd7a941b332b8e82a387b3bccd197adfce79fd2848d4eb190e9df37392a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysqueeze-0.1.1-py3-none-any.whl:

Publisher: publish.yml on Gerard-007/pysqueeze

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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