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,
    max_tokens=1600,  # downscale until the estimate fits; omit for no budget
    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.9.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.9.0
File Size Uploaded Provenance Actions
vision_squeezer-0.9.0.tar.gz 10.4 MB With provenance Details for vision_squeezer-0.9.0.tar.gz

Built distributions (wheels)

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

Total release size: 26.1 MB

Release files / vision_squeezer-0.9.0.tar.gz

Download URL vision_squeezer-0.9.0.tar.gz
Size 10.4 MB
Tags Source
SHA-256 checksum
How to use checksums
3904b602b6ee5577011cd5cb4e0acff15be2840801f23a78e88dc37fae783a9c
BLAKE2b-256 checksum
How to use checksums
96cc1f411c9621d572a9e0a74af67b36b958841c5a19704abf926a7410561662
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL vision_squeezer-0.9.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
414efd8312a20c20d584ea92a1c255809daa2fb839278467530c01edd51703f0
BLAKE2b-256 checksum
How to use checksums
c7420dc7b22569157ad0b506252da8dea285f2df3edba01647bc62afca7f284c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL vision_squeezer-0.9.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
41908bb889348c23859a6ea7710d7cca44e7d85fdcaaca395a53f13384f2828f
BLAKE2b-256 checksum
How to use checksums
bdbb308e1ccbc8f75401eb2b8ec27aa551249ee1bfc68ad8497b195463ad5090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL vision_squeezer-0.9.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
46e119566fa6aa21170ede6639f76968b03028f5c4f797cd260a513e23422dd5
BLAKE2b-256 checksum
How to use checksums
dfaf086f02c2c2cda49ff1d620a5c68ed39bc03ea5d6934090cb4f42d0b7dc6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL vision_squeezer-0.9.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
d30e53d249603dbf400e33202fd8451203d6dd7cc13e7948ee7bb6b573088619
BLAKE2b-256 checksum
How to use checksums
7b96c579f0c17b3a70fedf406d4afa7531608232d4b06f16760a9aa2366e5665
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

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

Download URL vision_squeezer-0.9.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
43980b51d349d9c0cc1538222e75f08cfa39d084ae6df76d2af4566186fe7e85
BLAKE2b-256 checksum
How to use checksums
90c23ac7dbf2fd0674b0a19d880a45620063b48b256023f7fd414b027dabbad6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

Security for vision-squeezer 0.9.0

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for vision_squeezer-0.9.0.tar.gz

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 Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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