Skip to content
Fourohtwo

Compress an image to a target file size

bild.halowerk.com/v1/compress-to-size

Compress an image to a target file size: binary search over encoder quality (JPEG, WebP or AVIF) above a quality floor, optionally reducing dimensions when the floor is not enough.

BaseAnswering
POSThttps://bild.halowerk.com/v1/compress-to-size

Uptime100% of 1 check in 30 days

30 days agoToday

Try it

Pays from your browser wallet in USDC on Base or USDG on Robinhood Chain, whichever the endpoint takes. The provider is paid directly; failed calls aren't refunded by Fourohtwo.

The response shows up here.

Call it from an agent

import { createPayer } from "fourohtwo";

// One agent key pays USDC on Base or USDG on Robinhood Chain,
// inside the spending rules you set on Fourohtwo.
const pay = createPayer({ privateKey: process.env.AGENT_KEY });
const res = await pay("https://bild.halowerk.com/v1/compress-to-size", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"format":"webp","image_base64":"iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFElEQVR4nGPgqjjxnxjMMKqQvgoBasrkhTND8CQAAAAASUVORK5CYII=","max_quality":80,"target_bytes":100000}),
});
console.log(await res.json());

Example input

{
  "format": "webp",
  "image_base64": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFElEQVR4nGPgqjjxnxjMMKqQvgoBasrkhTND8CQAAAAASUVORK5CYII=",
  "max_quality": 80,
  "target_bytes": 100000
}