Skip to main content

LLM-native image optimization — reduces vision model token consumption by snapping to tile boundaries

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vision_squeezer-0.6.0.tar.gz (10.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vision_squeezer-0.6.0-cp38-abi3-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.8+Windows x86-64

vision_squeezer-0.6.0-cp38-abi3-manylinux_2_28_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ x86-64

vision_squeezer-0.6.0-cp38-abi3-manylinux_2_28_aarch64.whl (3.0 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ ARM64

vision_squeezer-0.6.0-cp38-abi3-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file vision_squeezer-0.6.0.tar.gz.

File metadata

  • Download URL: vision_squeezer-0.6.0.tar.gz
  • Upload date:
  • Size: 10.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vision_squeezer-0.6.0.tar.gz
Algorithm Hash digest
SHA256 f62138447dab0bcec38e63e5f19909931c985c2e17af24e3fbafe2ddea4d250a
MD5 41b920291a487a3016f1660c04f8b324
BLAKE2b-256 9fc984f6affe781f90c38fc6983e9c5d7a79047cfd3e86dca8667c4b7b7dd9e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for vision_squeezer-0.6.0.tar.gz:

Publisher: python.yml on eralpozcan/vision-squeezer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vision_squeezer-0.6.0-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for vision_squeezer-0.6.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1a9daf82022bb8aa9aac19065035fd197eb21787aba33f820f4f0bfe4359ba42
MD5 99a5cf5dfa3f7c1e19b1424818240774
BLAKE2b-256 c69b36ee3f54ad7113dc4506d0dddc6ffd7e23b106bcb62c0b28b25ba0314d99

See more details on using hashes here.

Provenance

The following attestation bundles were made for vision_squeezer-0.6.0-cp38-abi3-win_amd64.whl:

Publisher: python.yml on eralpozcan/vision-squeezer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vision_squeezer-0.6.0-cp38-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vision_squeezer-0.6.0-cp38-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 02c1d9fb543f519beb95579de6adc52d81dab103ef9c16505d87ba77dfe61d20
MD5 353556f28068b80a88c68ef1932bb892
BLAKE2b-256 845f2d6828346fc74c4487e644d740013e6ce21a1ce7e3c0bda3a65e0dab2b6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for vision_squeezer-0.6.0-cp38-abi3-manylinux_2_28_x86_64.whl:

Publisher: python.yml on eralpozcan/vision-squeezer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vision_squeezer-0.6.0-cp38-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vision_squeezer-0.6.0-cp38-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 07e3c42097d26464bb579950b47e3784717c1bb096754b161324c4bdf6ccc289
MD5 3c0457d63848aabd9775302b13fb94c6
BLAKE2b-256 4b0e42553818fd874d5e9f95d82ec59af7bc191952892212ab99c46af3ebfc7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for vision_squeezer-0.6.0-cp38-abi3-manylinux_2_28_aarch64.whl:

Publisher: python.yml on eralpozcan/vision-squeezer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vision_squeezer-0.6.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for vision_squeezer-0.6.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 827c0b404e42768d05bafa2a34aa7117b584692f156a4df79473f4e2084b427b
MD5 e3caaddc13ecdf2b7f5487bb6fb652ba
BLAKE2b-256 652785404e48cb6503f397ba39192d3873e85c15fb4554051bcff6824f6cb483

See more details on using hashes here.

Provenance

The following attestation bundles were made for vision_squeezer-0.6.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: python.yml on eralpozcan/vision-squeezer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page