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.7.0

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.7.0
File Size Uploaded
vision_squeezer-0.7.0.tar.gz 10.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for vision-squeezer 0.7.0
File
vision_squeezer-0.7.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
vision_squeezer-0.7.0-cp38-abi3-manylinux_2_28_x86_64.whl CPython 3.8 abi3 Linux glibc 2.28+ x86-64 Details
vision_squeezer-0.7.0-cp38-abi3-manylinux_2_28_aarch64.whl CPython 3.8 abi3 Linux glibc 2.28+ ARM64 Details
vision_squeezer-0.7.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
vision_squeezer-0.7.0-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.7.0.tar.gz

Download URL vision_squeezer-0.7.0.tar.gz
Size 10.4 MB
Tags Source
SHA-256 checksum
How to use checksums
fc644be4df122ea0225120d6a91de3c1126d5d762555dfe05db5aeba7e8bb513
BLAKE2b-256 checksum
How to use checksums
9e46580cb291ed08744fd50c1d1bdba2b37ac487c3d196e9864807127fae324a
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.7.0-cp38-abi3-win_amd64.whl

Download URL vision_squeezer-0.7.0-cp38-abi3-win_amd64.whl
Size 3.7 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
82ed5776c9ff2e850067571d979e94a4bfdec76aa98161b704def72480a36d62
BLAKE2b-256 checksum
How to use checksums
8e93135b71b756a40fb7a92b2702e3c6ffd63beedbbc674ff8ff9b582a0044ea
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.7.0-cp38-abi3-manylinux_2_28_x86_64.whl

Download URL vision_squeezer-0.7.0-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
bfa8d9541cfe5388abd22fa6d511d23988dd4e1b21d1c9c7fc9c9e7d38ac1260
BLAKE2b-256 checksum
How to use checksums
a3fc429497fa989b1338a4ba3185a3f8f3892579a691ab92c7e2fb3dc437f02d
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.7.0-cp38-abi3-manylinux_2_28_aarch64.whl

Download URL vision_squeezer-0.7.0-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
c1b2f73486d9bd3b5624ef3fb0ed3512a8f7db7a61e921d17ee32c1824001a38
BLAKE2b-256 checksum
How to use checksums
ab8c0f8ab5509565c39d3ea9fc84221af8a83d11d198c3f2f7e4644a633a7d52
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.7.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL vision_squeezer-0.7.0-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
8a89544276d07f0489df93b92884223ff01820baf7868d987a131846ea136e8f
BLAKE2b-256 checksum
How to use checksums
2b9048793808305e34b6aa464aa1a01d7a0c7b63e33999f72d340d2460dbca45
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.7.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL vision_squeezer-0.7.0-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
f76f8b48e2ba93adfe3052bb1d6aa427da938f94f83a4be9be6ca2707ded98e7
BLAKE2b-256 checksum
How to use checksums
5f339a9a6b0a232add3cf26db70a78b5540869287b044ca1d15196eb7d426244
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

This release

0.7.0 This release

6 release files

0.6.2

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