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.8.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.8.0
File Size Uploaded
vision_squeezer-0.8.0.tar.gz 10.4 MB Details

Built distributions (wheels)

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

Total release size: 26.1 MB

Release files / vision_squeezer-0.8.0.tar.gz

Download URL vision_squeezer-0.8.0.tar.gz
Size 10.4 MB
Tags Source
SHA-256 checksum
How to use checksums
1f01921a92892cec7b7810d07f196e8983b03eca861cf564ebcf29c01f238f8c
BLAKE2b-256 checksum
How to use checksums
3828ed3efc55f7ea4af41aef56f5702408f2aaf9f61637c53ee2e412afcba74a
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 Oct 1, 2026.

Transparency log

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

Download URL vision_squeezer-0.8.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
f91094aa42db2a5eba04f6b1be957091221a30f22126e3974c323b5033d7bd0b
BLAKE2b-256 checksum
How to use checksums
0a4621f77f0e5b193e466132a6ddd63dcfbb0215c1c203f57e3476f81a780b07
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 Oct 1, 2026.

Transparency log

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

Download URL vision_squeezer-0.8.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
41845730d817be9c72772a1465ec59ee1311ee857f577dffed157a5d5d19773e
BLAKE2b-256 checksum
How to use checksums
4ae5cdce4ca5b51ace79db4c5601b7c1814564bfcf8d9c5b6a470efe40e2dede
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 Oct 1, 2026.

Transparency log

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

Download URL vision_squeezer-0.8.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
f7a3f571898f5dbf818a2bd56e6ae1b69a9dbe70f3776258feab02099dea90a1
BLAKE2b-256 checksum
How to use checksums
a15bf7be9eac13b43c0a155d4c29a24a37c98911ad61b8c95fd9b7387d184315
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 Oct 1, 2026.

Transparency log

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

Download URL vision_squeezer-0.8.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
f229c216a4b42aa9739f298f97febb86aa3c2f2fb607dccc0e97224724fbdbd4
BLAKE2b-256 checksum
How to use checksums
4904188b386faa134c243c257f7c130b8719c0845659d2ca9d6b1659fbdb0723
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 Oct 1, 2026.

Transparency log

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

Download URL vision_squeezer-0.8.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
9dd94ba7521b56906c18ec46fa82cf7627c5e4664ee95c95c06c30541f06a3a8
BLAKE2b-256 checksum
How to use checksums
c3b5a994bd439900b442b01195a81207bc0f3c31bcbc5304461096fe955cb3c6
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 Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

0.8.1

6 release files

This release

0.8.0 This release

6 release files

0.7.1

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