Structs§
- Dimension
Result - Optimization
Report - Optimize
Result - Persistence
- Process
Config - All tuneable knobs for the pipeline.
- Process
Config Builder - Process
Result - Savings
Report - Squeezer
Stats - Token
Estimate - Token
Savings Table - Full token savings report for a before/after dimension pair across all models.
Enums§
- ImageOp
- Atomic image operations for the Sandbox mode.
- Output
Format - Output encoding format.
- Process
Mode - Vision
Model - Supported vision model families with their patch pricing.
Functions§
- binarize
- calculate_
optimal_ dimensions - Snap W×H to tile boundaries using default tile size (512).
- calculate_
optimal_ dimensions_ with - Snap W×H to tile boundaries using a custom tile size.
- crop_
padding - Remove solid-color borders using corner sampling + configurable tolerance.
- decode_
base64_ image - detect_
ocr_ mode - encode_
image_ base64 - encode_
to_ bytes - Encode image to raw bytes using the configured output format.
- encode_
with_ auto_ quality - Binary-search the lowest quality in [
min_q,max_q] that meets a given SSIM target against the original. Returns the encoded bytes and the quality used. - estimate_
tokens - Estimate LLM vision tokens for an image of given dimensions.
- fit_
within - Scale dimensions to fit within
max_sidewhile preserving aspect ratio. - fit_
within_ pixels - Scale dimensions to fit within both a max-side limit and a total-pixel limit.
- optimal_
send_ dimensions - Compute the optimal dimensions to send to a given model to minimize tiles.
- optimize_
image - MCP entry point: base64 in → base64 JPEG out + savings report.
- process
- Full pipeline: [crop] → tile-snap resize → [OCR binarize].
Pass
input_bytes = 0if unknown (omits file-size from report). - process_
with_ operations - Execute a sequence of operations on an image.
- saliency_
crop - Crop to the bounding box of high-energy (edge) pixels.
Uses a Sobel-lite gradient magnitude per luma pixel. Pixels above 2× the
mean gradient energy define the salient region; the bbox is expanded by
marginpixels on every side. - ssim
- Compute structural-similarity (single-window, luma) between two images.
- token_
savings_ table