Skip to main content
Glama

optimize_generated_image

Optimize an AI-generated image for the web

The step after image generation. gpt-image, DALL-E, Flux, Midjourney and Stable Diffusion hand back 2-8 MB PNGs; this returns the same picture as a web-ready webp (default), avif, jpeg or png, metadata stripped, transparency kept on webp/avif/png. Optional max_dimension caps the longest side (never upscales); optional q or quality_target (smallest file with SSIM >= target, flat surcharge) control quality. Same price as convert. If the result is not smaller than the input it is still returned but free (X-Pig-Billed: 0). X-Pictomancer-Bytes-Before/-After/-Saved-Percent report the saving. The input's C2PA manifest, if any, is reported in X-Pictomancer-C2PA-Input but is not carried over: re-encoding invalidates it.

Responses:

200: Processed image binary (Success Response) Content-Type: application/json Content-Type: image/jpeg

Example Response:

"string"

Content-Type: image/png

Example Response:

"string"

Content-Type: image/webp

Example Response:

"string"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qNoQuality (1-100). Maps to libvips Q parameter. Omit to use the encoder default; or set quality_target instead.
stripNoStrip metadata. Defaults to true: generated images carry no EXIF worth keeping. Metadata includes any C2PA manifest, which would be invalid after re-encoding anyway.
formatNoOutput format: webp (default), avif, jpeg or png. webp, avif and png keep transparency; jpeg flattens it.webp
sourceYesImage source: a public URL (https://...) or a base64-encoded string (optionally as a data URI like data:image/png;base64,...).
deliveryNo
max_dimensionNoCap on the longest side in pixels. Larger images are scaled down to fit, aspect ratio preserved; smaller images are never upscaled.
quality_targetNoTarget SSIM (0-1]: the worker searches for the smallest file that still scores at least this. Alternative to q; mutually exclusive with it. Carries a flat surcharge for the extra encodes.

TDQS

A5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses key behaviors without annotations: metadata stripping (including C2PA), no upscaling, surcharge for quality_target, and the 'free if not smaller' rule. It also explains security aspects of PUT/callback delivery (no credential storage, HMAC signing, SSRF whitelisting).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured paragraph that front-loads the purpose and systematically covers options, costs, and security. It is dense but not verbose, conveying substantial information efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers all major aspects: purpose, delivery modes, quality controls, metadata handling, cost, and response behavior (including binary output and free condition). It is complete given the tool's complexity and the provided schema, with no significant gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

It enriches schema descriptions with contextual details: format transparency handling, delivery mode security, and cost implications (same price as convert, flat surcharge). The description adds meaning beyond the schema, such as the condition for free result.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Optimize an AI-generated image for the web' and specifies it as the step after image generation. This distinguishes it from sibling tools like compress_image or convert_image by targeting AI-generated output and web readiness.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly indicates when to use this tool ('The step after image generation') and compares pricing to convert, implying alternatives. It also covers delivery modes and quality controls, giving clear guidance on scenarios like async delivery via callback URLs or cost implications of quality_target.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

TDQS

A3.9/5.0
Disambiguation3/5

Most tools are distinct, but compress_image, convert_image, and optimize_generated_image overlap heavily: all re-encode images with format and quality options. The descriptions clarify intent, yet an agent could still struggle to pick between compressing, converting, and optimizing in some cases.

Naming Consistency4/5

The set mostly follows a verb_noun pattern (analyze_image, compress_image, crop_image, resize_image). Minor deviations include image_pipeline, which is a noun phrase, and optimize_for_vision/optimize_generated_image, which use longer prepositional forms, but the overall pattern is predictable.

Tool Count5/5

Ten tools is well within the ideal range for an image-processing server. Each tool serves a meaningful purpose, and the count feels neither bloated nor thin.

Completeness4/5

Core image operations are well covered: analyze, resize, crop, convert, compress, pipeline, plus cost/format introspection. Minor gaps like rotate/flip or explicit metadata editing are absent, but agents can accomplish most workflows with the existing surface.

Resources