compress.target: hit a size or quality bar
Compress an image, video, or audio file to the smallest size that clears a quality bar. Named tiers or byte targets, with AVIF, JPEG XL, AV1, Opus, and more.
compress.target is now available to every workspace. Give it a media URL and a target, and the encoder searches candidate encodes, scores each one with a perceptual metric (ssimulacra2 for images, VMAF for video), and returns the smallest file that still clears your quality bar, plus a report of what it did.
import { createClient } from "@rendobar/sdk";
const client = createClient({ apiKey: process.env.RENDOBAR_API_KEY });
const job = await client.jobs.create({ type: "compress.target", inputs: { source: "https://example.com/photo.jpg" }, params: { target: "balanced", for: "web" },});What the report looks like
A real run against a 763 KB PNG, for: "web" and target: "balanced":
{ "verdict": "high", "codec": "avif", "metric": "ssimulacra2", "achievedScore": 85.28, "compressionRatio": 12.1, "originalBytes": 781514, "outputBytes": 64751, "probes": 5}The same call against an already-efficient 179,208 byte JPEG comes back "verdict": "passthrough" with "compressionRatio": 1 and the input bytes returned unchanged. It still ran 5 probes and scored 86.01. None of the candidates beat the original, so it handed the original back rather than spending your credits to make the file no smaller.
Targets and options
targettakes a named tier (visually-lossless,balanced,efficient), a bare quality number from 1 to 100, or a single goal object like{ maxSize: "500kb" }or{ bitrate: 128 }.- Works on video, images, and audio. With
codec: "auto"the pick respects acompatibilityreach (modern,broad,legacy), or pin one of AV1, HEVC, H.264, VP9, AVIF, JPEG XL, jpegli, WebP, PNG, Opus, AAC, MP3, FLAC, or ALAC. - The report is honest. When no encode beats your original, you get the original back with
verdict: "passthrough", because a well-optimized input is a valid answer. When a target is unreachable, the report says so instead of shipping a silent miss. dryRun: truereturns the predicted size and score without producing a file.maxResolutioncaps the longest edge.video.audioTracks,audio.loudnessLufs, andaudio.channelsshape the tracks. Audio bitrates are channel-aware, so a mono voice track gets a mono budget.for: "web"strips metadata for delivery.for: "archive"produces a lossless master instead: PNG, FFV1, or FLAC.- Long videos keep the search cheap by probing short samples, and only the final encode runs over the whole file.
The reference page covers the report shape, target modes, and the codec ladder. Or try it without writing code in the dashboard playground.
The search that picks the encode got substantially faster later, see compress runs 2 to 3x faster.
