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.

post/v1/optimize_generated

Request

  • Base URL: https://api.pictomancer.ai (the document declares no server; this is the origin it was published from)
  • URL: https://api.pictomancer.ai/v1/optimize_generated
  • Auth: none declared

Request body

sourcestring required

Image source: a public URL (https://...) or a base64-encoded string (optionally as a data URI like data:image/png;base64,...).

formatstring

Output format: webp (default), avif, jpeg or png. webp, avif and png keep transparency; jpeg flattens it.

qinteger nullable

Quality (1-100). Maps to libvips Q parameter. Omit to use the encoder default; or set quality_target instead.

quality_targetnumber nullable

Target 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.

max_dimensioninteger nullable

Cap on the longest side in pixels. Larger images are scaled down to fit, aspect ratio preserved; smaller images are never upscaled.

stripboolean

Strip metadata. Defaults to true: generated images carry no EXIF worth keeping. Metadata includes any C2PA manifest, which would be invalid after re-encoding anyway.

Response

Processed image binary

unknown required

Changes

No recorded changes to this operation across all 1 revision of this API.