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

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

Built distributions (wheels)

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

Download URL vision_squeezer-0.7.1.tar.gz
Size 10.4 MB
Tags Source
SHA-256 checksum
How to use checksums
778e69eab1dd89b7f10a9a524d1932430fad64a49bcb801eaa081965846b7427
BLAKE2b-256 checksum
How to use checksums
2677eeea92b4668ff84cfd0e009f80b4b2747a359c9b7e0e0ea4081f8e4c69af
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.1-cp38-abi3-win_amd64.whl

Download URL vision_squeezer-0.7.1-cp38-abi3-win_amd64.whl
Size 3.7 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0d5e393afce1a7e28cbdd3f2ae6eb04ebe114902b96e2a7cd627048ac1421eb6
BLAKE2b-256 checksum
How to use checksums
e3c48e410f7f0eaf1b3027cf2e16528a8c742a4070c426d7891681b809c39a98
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.1-cp38-abi3-manylinux_2_28_x86_64.whl

Download URL vision_squeezer-0.7.1-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
e9f2d1bda1eacb6da5c4206a4465783f6acdc8c0b03cb24fd9f0552836b16278
BLAKE2b-256 checksum
How to use checksums
8c826b51da34da699953c20e174f87ac43268ce4cb9e0b5a9ceb43da9eb55bb8
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.1-cp38-abi3-manylinux_2_28_aarch64.whl

Download URL vision_squeezer-0.7.1-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
5fe802cbcf135614755aec151c012fb20689ea66c5c69dce43d6a7e786d80050
BLAKE2b-256 checksum
How to use checksums
3f477c31f5c47eb2cab3fadd9fbfc87a256450c6675941722e5843e493395c76
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.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL vision_squeezer-0.7.1-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
8e368d9a7eb250afbd8cde2559b825affe741a7b5b9d14fd2ed311543e0cc041
BLAKE2b-256 checksum
How to use checksums
4e8c8be039ff68f97b3c969d10db7dbde4b3f89cbbdeab5927ac1c0b1a60d01b
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.1-cp38-abi3-macosx_10_12_x86_64.whl

Download URL vision_squeezer-0.7.1-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
5f20e573623301a3b6463a3fdae37dee8324499aee14bbde3c6afaf752156fc2
BLAKE2b-256 checksum
How to use checksums
0ae85ceb155815d8e6089f0b917171f1f32196c01616bcf0926f5b1d4c368fbd
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

This release

0.7.1 This release

6 release files

0.7.0

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