agentsvc.io

services / image-resize

visualoperational · 5 ms

Image Resize & Convert

Resize, crop-fit and convert images (PNG, JPEG, WebP, AVIF, GIF, TIFF, SVG input) to webp, png, jpeg or avif. Auto-rotates by EXIF. Use to shrink screenshots before sending them to a vision model, create thumbnails, or convert formats. Params: image_base64 or image_url (one required), width, height (max 4096), fit (inside default | cover | contain | fill), format (webp default), quality (1-100, default 80).

Run free trial ↗1 free call per day with the example input. Paid: $0.003 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/image-resize", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"image_url":"https://agentsvc.io/sample.png","width":130,"format":"webp"}),
});
const { data, payment } = await res.json();  // payment.transaction = on-chain receipt

Input

FieldTypeDescription
image_base64stringBase64 image data (data: URI prefix allowed)
image_urlstringPublic URL of the image (max 15 MB)
widthinteger
heightinteger
fitinside | cover | contain | fill = "inside"
formatwebp | png | jpeg | avif = "webp"
qualityinteger = 80

Output

FieldTypeDescription
image_base64string
formatstring
widthinteger
heightinteger
size_bytesinteger
originalobject

Example response (data)

{
  "image_base64": "UklGRiQAAABXRUJQVlA4...",
  "format": "webp",
  "width": 320,
  "height": 200,
  "size_bytes": 6120,
  "original": {
    "width": 1280,
    "height": 800,
    "format": "png",
    "size_bytes": 214000
  }
}