Skip to main content

vision-squeezer (Python)

Python bindings for vision-squeezer — LLM-native image optimization. Reduces vision model token consumption by snapping to tile boundaries.

Install

pip install vision-squeezer

From source (requires Rust + pip install maturin):

cd python && maturin develop --release

Usage

import vision_squeezer as vs

# Optimize an image on disk and write next to it.
report = vs.optimize_image(
    "screenshot.png",
    model="claude",
    quality=75,
    output_path="screenshot.optimized.jpg",
)
print(f"Saved {report['tokens_saved']} tokens, {report['size_reduction_pct']:.1f}% smaller")

# Or work with raw bytes.
with open("screenshot.png", "rb") as f:
    raw = f.read()
report = vs.optimize_image(raw, model="gpt4o", format="webp")
# report["bytes"] holds the optimized image
# report["base64"] is the same image, base64-encoded

# Estimate tokens without optimizing.
est = vs.estimate_tokens(4096, 3072, model="claude")
print(est)  # {'model': 'claude', 'tokens': ..., 'tiles': ...}

# Optimal send dimensions for a given model.
print(vs.optimal_dimensions(4096, 3072, model="gpt4o"))

Supported models

  • claude (3.5 / 4.x — area-based token estimation)
  • gpt4o (GPT-4o / 4.5 — 2048 fit then 768 short-side, 512px tiles)
  • gpt5 (GPT-5/5.5 — 6000px max, 10.24M pixel cap, 1536 token cap)
  • gemini (Gemini 2.0/3.0 — flat 258 ≤384×384, else 768px tiles)

Output formats

jpeg (default) and webp. Format affects bytes, not tokens.

Metadata

Release files for vision-squeezer 0.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vision-squeezer 0.6.2
File Size Uploaded
vision_squeezer-0.6.2.tar.gz 10.3 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for vision-squeezer 0.6.2
File
vision_squeezer-0.6.2-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
vision_squeezer-0.6.2-cp38-abi3-manylinux_2_28_x86_64.whl CPython 3.8 abi3 Linux glibc 2.28+ x86-64 Details
vision_squeezer-0.6.2-cp38-abi3-manylinux_2_28_aarch64.whl CPython 3.8 abi3 Linux glibc 2.28+ ARM64 Details
vision_squeezer-0.6.2-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
vision_squeezer-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details

Total release size: 26.0 MB

Release files / vision_squeezer-0.6.2.tar.gz

Download URL vision_squeezer-0.6.2.tar.gz
Size 10.3 MB
Tags Source
SHA-256 checksum
How to use checksums
3689b3ad89271ea7dd28a743fd8ae1af97d958d547b0197890d5ac5be198aecd
BLAKE2b-256 checksum
How to use checksums
4086a98f57bc5ecd2330cc84f7a32cad199c6ca24617a6cf0a34949058b68db1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / vision_squeezer-0.6.2-cp38-abi3-win_amd64.whl

Download URL vision_squeezer-0.6.2-cp38-abi3-win_amd64.whl
Size 3.7 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2771e93e1530ec3429bd331d5747957289eb6e37ba837c9333012fee4bba9cb6
BLAKE2b-256 checksum
How to use checksums
422bd41bfa62238eb64bfc9fbd462ba6463306d225a9e601d4f250a5d0592839
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / vision_squeezer-0.6.2-cp38-abi3-manylinux_2_28_x86_64.whl

Download URL vision_squeezer-0.6.2-cp38-abi3-manylinux_2_28_x86_64.whl
Size 3.2 MB
Tags CPython 3.8 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
22db2e8cd6d026c4d5ae3ca8c78ca9677be826b387cc5df22377f36517d19127
BLAKE2b-256 checksum
How to use checksums
0535937eb6e776a2bab4c6e6354afaac594ffdabfd67a602bc88109e74651c8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / vision_squeezer-0.6.2-cp38-abi3-manylinux_2_28_aarch64.whl

Download URL vision_squeezer-0.6.2-cp38-abi3-manylinux_2_28_aarch64.whl
Size 3.1 MB
Tags CPython 3.8 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
58e6f35633432a41b5067455c0479f76d2b5f81a3b08625f7b53f0566fff3f36
BLAKE2b-256 checksum
How to use checksums
d1ee2395e3d13e808c0dd3a0cabb40cc65114278f8b0fe55cbd88c2b93dd4294
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / vision_squeezer-0.6.2-cp38-abi3-macosx_11_0_arm64.whl

Download URL vision_squeezer-0.6.2-cp38-abi3-macosx_11_0_arm64.whl
Size 2.8 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
03e71c4d059611c4d7549a3edca3df65a08aa00a7233a416c0005e3533bff606
BLAKE2b-256 checksum
How to use checksums
699525b9a6efec1db88543d14cd712787d0744fe02fe1ac38a454535c36c02cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release files / vision_squeezer-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl

Download URL vision_squeezer-0.6.2-cp38-abi3-macosx_10_12_x86_64.whl
Size 3.0 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
27992b9025bc1d37e7d51183eab6307668b43141e373ff0f725f6d2ffbdd55ee
BLAKE2b-256 checksum
How to use checksums
fdf6f3ad79f3e02940b920d87b71135d10876c64d8a27c8dc1e6f5fa3cfc768c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.

Transparency log

Release history Release notifications | RSS feed

0.8.1

6 release files

0.8.0

6 release files

0.7.1

6 release files

0.7.0

6 release files

This release

0.6.2 This release

6 release files

0.6.0

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page